Search Results

Search found 41 results on 2 pages for 'wyatt barnett'.

Page 2/2 | < Previous Page | 1 2 

  • Accessing a webpage in C++

    - by wyatt
    Is there a good, simple library which allows C++ to load a webpage? I just want to grab the source as text. I'm not using any IDE or significant library, just straight command line. Tangentially, is there something fundamental I'm missing about programming in C++? I would think any language in common use today would have droves of web-based functionality, being so central to computer usage, but I can find next to no discussion on how to accomplish it. I realise C++ significantly predates the modern internet, so it lacking any core ability in the regard is reasonable, but the fact that relevant libraries seem so sparse is baffling. Thanks for your help.

    Read the article

  • Class destructor memory handling in C++

    - by wyatt
    What potential memory leaks won't an implicit destructor handle? I know that if you have anything stored on the heap it won't handle it, and if you have a connection to a file or a database, that needs to be handled manually. Is there anything else? What about, say, non-base data types like vectors? Also, in an explicit destructor, need you destroy non-heap variables which would have been destroyed by the implicit, or are they handled automatically? Thanks

    Read the article

  • variables in abstract classes C++

    - by wyatt
    I have an abstract class CommandPath, and a number of derived classes as below: class CommandPath { public: virtual CommandResponse handleCommand(std::string) = 0; virtual CommandResponse execute() = 0; virtual ~CommandPath() {} }; class GetTimeCommandPath : public CommandPath { int stage; public: GetTimeCommandPath() : stage(0) {} CommandResponse handleCommand(std::string); CommandResponse execute(); }; All of the derived classes have the member variable 'stage'. I want to build a function into all of them which manipulates 'stage' in the same way, so rather than defining it many times I thought I'd build it into the parent class. I moved 'stage' from the private sections of all of the derived classes into the protected section of CommandPath, and added the function as follows: class CommandPath { protected: int stage; public: virtual CommandResponse handleCommand(std::string) = 0; virtual CommandResponse execute() = 0; std::string confirmCommand(std::string, int, int, std::string, std::string); virtual ~CommandPath() {} }; class GetTimeCommandPath : public CommandPath { public: GetTimeCommandPath() : stage(0) {} CommandResponse handleCommand(std::string); CommandResponse execute(); }; Now my compiler tells me for the constructor lines that none of the derived classes have a member 'stage'. I was under the impression that protected members are visible to derived classes? The constructor is the same in all classes, so I suppose I could move it to the parent class, but I'm more concerned about finding out why the derived classes aren't able to access the variable. Also, since previously I've only used the parent class for pure virtual functions, I wanted to confirm that this is the way to go about adding a function to be inherited by all derived classes.

    Read the article

  • Exclude subexpression from regexec in c++

    - by wyatt
    Suppose I was trying to match the following expression using regex.h in C++, and trying to obtain the subexpressions contained: /^((1|2)|3) (1|2)$/ Suppose it were matched against the string "3 1", the subexpressions would be: "3 1" "3" "1" If, instead it were matched against the string "2 1", the subexpressions would be: "2 1" "2" "2" "1" Which means that, depending on how the first subexpression evaluates, the final one is in a different element in the pmatch array. I realise this particular example is trivial, as I could remove one of the sets of brackets, or grab the last element of the array, but it becomes problematic in more complicated expressions. Suppose all I want are the top-level subexpressions, the ones which aren't subexpressions of other subexpressions. Is there any way to only get them? Or, alternatively, to know how many subexpressions are matched within a subexpression, so that I can traverse the array irrespective of how it evaluates? Thanks

    Read the article

  • kill a process in bash

    - by wyatt
    How do I kill a process which is running in bash - for example, suppose I open a file: $ gedit file.txt is there any way within the command prompt to close it? This example is fairly trivial, since I could just close the window, but it seems to come up a bit, particularly when I mistype commands. Also is there any way to escape an executable which is running? This probably has the same solution, but I thought I'd ask anyway. Thanks

    Read the article

  • Overinclusion of libraries C++

    - by wyatt
    I'm reading about how to put a makefile together, but no-one seems to mention what to do if your files require different sets of libraries, they all seem to use the same set of libraries for each file. Since it seems unlikely that every single file has the same libraries, I take it the list they use must amalgamate all of the libraries required across the project. I just wanted to know if there's any downside to including too many libraries, or if the compiler works out which ones are needed and ignores the rest? Thanks

    Read the article

  • Class lookup structure array in C++

    - by wyatt
    I'm trying to create a structure array which links input strings to classes as follows: struct {string command; CommandPath cPath;} cPathLookup[] = { {"set an alarm", AlarmCommandPath}, {"send an email", EmailCommandPath}, {"", NULL} }; which will be used as follows: CommandPath *cPath = NULL; string input; getline(cin, input); for(int i = 0; cPathLookup[i] != ""; i++) { if(cPathLookup[i].command == input) cPath = new cPathLookup[i].cPath; } Obviously, this code is meaningless, but I think my intention is apparent - depending on input, I'd like cPath to be initialized as either a new AlarmCommandPath or a new EmailCommandPath. I could handle it with a function returning an instance depending on input, but a whole sequence of ifs just seems inelegant. I should also note that, in case it's not apparent and important, that AlarmCommandPath and EmailCommandPath are derived from CommandPath, and CommandPath is an abstract class. Thanks for any help you can offer. EDIT: I just noticed that, in spite of CommandPath being abstract, I have a declaration: CommandPath *cPath = NULL; in working code. Why does that compile?

    Read the article

  • How do i pass a number from a list as a parameter in scheme?

    - by wyatt
    I need to take a number from a list and convert it to a number so that i can pass it as a parameter. im trying to make a 1-bit adder in scheme. i've written the code for the or gate and the xor gate and also the half adder and now im trying to combine them all to make a full adder. im not sure if im going about it the right way. any input will be appreciated thank you. (define or-gate (lambda (a b) (if (= a 1) 1 (if (= b 1) 1 0)))) (define xor-gate (lambda (a b) (if (= a b) 0 1))) (define ha (lambda (a b) (list (xor-gate a b)(and-gate a b)))) (define fa (lambda (a b cin) (or-gate (cdr(ha cin (car (ha a b))))(cdr(ha a b))))) the issue i get when i run the program is that the half adder (ha) function outputs a list as a value and that makes the values incompatible with my other procedures because they require numbers and not lists. i feel like there is a simple solution but i dont know it.

    Read the article

  • C++ passing arguments to a program already running

    - by wyatt
    I'm reading through a tutorial on using voice commands to control applications and, in an example of controlling rhythmbox, it suggests commands such as the following can be executed: rhythmbox-client --play rhythmbox-client --pause Why does this not simply open a new instance of the program, and how can I emulate the functionality in my own programs? For example, how could I pass a string to a particular instance of a program? Thanks

    Read the article

  • Multithreaded SDL error in C++

    - by wyatt
    I'm building a program in C++, using SDL, and am occasionally receiving this error: * glibc detected * ./assistant: double free or corruption (!prev) It's difficult to replicate, so I can't find exactly what's causing it, but I just added a second thread to the program, and neither thread run on its own seems to cause the error. The threads don't share any variables, though they both run the functions SDL_BlitSurface and SDL_Flip. Could running these concurrently throw up such an error, or am I barking up the wrong tree? If this is the cause, should I simply throw a mutex around all SDL calls? Thanks

    Read the article

  • compiling a c++ program including mysql

    - by wyatt
    I'm new to gcc, and trying to compile a c++ program which includes mysql.h using the command: g++ -o test test.cpp -L/usr/include/mysql -lmysqlclient -I/usr/include/mysql It works without issue, but I was wondering if someone could explain the arguments to me. I don't like using commands I don't understand. Thanks

    Read the article

  • Exclude subexpression from regex in c++

    - by wyatt
    Suppose I was trying to match the following expression using regex.h in C++, and trying to obtain the subexpressions contained: /^((1|2)|3) (1|2)$/ Suppose it were matched against the string "3 1", the subexpressions would be: "3 1" "3" "1" If, instead it were matched against the string "2 1", the subexpressions would be: "2 1" "2" "2" "1" Which means that, depending on how the first subexpression evaluates, the final one is in a different element in the pmatch array. I realise this particular example is trivial, as I could remove one of the sets of brackets, or grab the last element of the array, but it becomes problematic in more complicated expressions. Suppose all I want are the top-level subexpressions, the ones which aren't subexpressions of other subexpressions. Is there any way to only get them? Or, alternatively, to know how many subexpressions are matched within a subexpression, so that I can traverse the array irrespective of how it evaluates? Thanks

    Read the article

  • functionality of cin in c++

    - by wyatt
    I'm a bit confused by the results of the following function: int main() { string command; while(1) { cin >> command; if(command == "end") return 0; else cout << "Could you repeat the command?" << endl; } return 0; } First of all - the output line ("could you...") repeats once for each individual word in the input (stored in command). So far as I can see, it should only be possible for it to happen once for each instance of the loop. Also, when the line 'if(command == "end")' is changed to 'if(command == "that's all")' it never triggers. A little testing suggested that all of the whitespace was removed from the command. Could someone explain to me what's going on here? Thanks

    Read the article

  • Why does 'sort' ignore special characters, like the asterisk?

    - by Aaron Digulla
    I thought that sort would sort common prefixes together but that doesn't always happen. Take this input for example: AT0S*eightieths AT0S*eyetooth's AT*ad AT*Ad AT*AD AT*Eydie AT*eyed ATF*adv ATF*ATV ATF*edify ATF*Ediva ATFKT*advocate ATFKTNK*advocating ATFKT*outfought ATFKTS*advocates ATHT*whitehead ATHT*Whitehead AT*id AT*I'd AT*Ito AT*IUD ATJ*adage ATNXNS*attention's ATNXNS*attenuation's ATNXNS*autoignition's AT*oat AT*OD AT*outweigh AT*owed ATP0K*idiopathic ATP*adobe ATT*wighted ATT*witted ATT*wooded AT*UT AT*Uta AT*wowed AT*Wyatt ATX*atishoo After sort, I'd expect all the AT* to end up in one chunk but when you run this data through sort, the output == input. Why is that? I'm not specifying any option to ignore non-alphabetic characters or anything. Just sort dict > out. My version of sort comes from coreutils 8.5-1ubuntu3.

    Read the article

  • Purpose oriented user accounts on a single desktop?

    - by dd_dent
    Starting point: I currently do development for Dynamics Ax, Android and an occasional dabble with Wordpress and Python. Soon, I'll start a project involving setting up WP on Google Apps Engine. Everything is, and should continue to, run from the same PC (running Linux Mint). Issue: I'm afraid of botching/bogging down my setup due to tinkering/installing multiple runtimes/IDE's/SDK's/Services, so I was thinking of using multiple users, each purposed to handle the task at hand (web, Android etc) and making each user as inert as possible to one another. What I need to know is the following: Is this a good/feasible practice? The second closest thing to this using remote desktops connections, either to computers or to VM's, which I'd rather avoid. What about switching users? Can it be made seamless? Anything else I should know? Update and clarification regarding VM's and whatnot: The reason I wish to avoid resorting to VM's is that I dislike the performance impact and sluggishness associated with it. I also suspect it might add a layer of complexity I wish to avoid. This answer by Wyatt is interesting but I think it's only partly suited for requirements (web development for example). Also, in reference to the point made about system wide installs, there is a level compromise I should accept as experessed by this for example. This option suggested by 9000 is also enticing (more than VM's actually) and by no means do I intend to "Juggle" JVMs and whatnot, partly due to the reason mentioned before. Regarding complexity, I agree and would consider what was said, only from my experience I tend to pollute my work environment with SDKs and runtimes I tried and discarded, which would occasionally leave leftovers which cause issues throught the session. What I really want is a set of well defined, non virtualized sessions from which I can choose at my leisure and be mostly (to a reasonable extent) safe from affecting each session from the other. And what I'm really asking is if and how can this be done using user accounts.

    Read the article

  • Al Zimmermann's Son of Darts

    - by polygenelubricants
    There's about 2 months left in Al Zimmermann's Son of Darts programming contest, and I'd like to improve my standing (currently in the 60s) to something more respectable. I'd like to get some ideas from the great community of stackoverflow on how best to approach this problem. The contest problem is known as the Global Postage Stamp Problem in literatures. I don't have much experience with optimization algorithms (I know of hillclimbing and simulated annealing in concept only from college), and in fact the program that I have right now is basically sheer brute force, which of course isn't feasible for the larger search spaces. Here are some papers on the subject: A Postage Stamp Problem (Alter & Barnett, 1980) Algorithms for Computing the h-Range of the Postage Stamp Problem (Mossige, 1981) A Postage Stamp Problem (Lunnon, 1986) Two New Techniques for Computing Extremal h-bases Ak (Challis, 1992) Any hints and suggestions are welcome. Also, feel free to direct me to the proper site if stackoverflow isn't it.

    Read the article

< Previous Page | 1 2