107 Posted Topics
Re: Without having code that compiles... The signature may be incorrect. void insertNode(T); Seems like you want to insert a node, not a type, which is represented by T? | |
Re: do you have a class threevector? most probably fourvector contains the threevector member variable fourvector constructor is initializing the three vector constructor | |
Re: Instead of timing how long it takes to run qsort sort once, execute qsort n times in a loop and see how long that takes. Vary n, until you get a reasonalble time. // startTime; for (size_t i=0 i < 100000; i++ ) { qsort(); } // endTime | |
Re: use the CODE blocks to demark your code, so its simpler to read [CODE] class Hello { }; [/CODE] | |
Re: If you don’t initialize your variables, you will get garbage... garbage in this case is any value that int is capable of representing... | |
Re: Its usually a good idea to put a include guard on you header files to prevent conflicts if they are included multiple times. Alternatively you can use #pragma once, although its not part of the standard. [CODE] #ifndef HEAP_H #define HEAP_H class Heap { public: }; #endif [/CODE] | |
Re: Basic algorithm is to find a space and then remove all subsequent spaces. Check out some of the std::string methods (find, erase) [url]http://www.cplusplus.com/reference/string/string/[/url] | |
Re: The code does not make any sense. Would be helpful to describe what you are trying to do in words. For example what are you trying to do with the while loop? What is the problem you're trying to solve? | |
Re: Why are we casting the pipebuf into a class?? | |
Re: In c/c++ its a good idea to initialize variables to some known state. Unintialized variables causing problem has kept many a programmer debugging for hours. In C++ Null is defined as 0. See section on "Should I use NULL or 0?" for some words of wisdom from the master himself. … | |
Re: Iterate through the vector and use string find/replace | |
Re: Below is one way to break it into token... [CODE] #include <sstream> #include <string> #include <iostream> int main() { std::stringstream ipv6("2001:0db8:0000:0000:0000:0000:1428:57a"); char seperator=':'; std::string token; const size_t MAX_BYTE=8; for( size_t i=0; i < MAX_BYTE; i++ ) { std::getline(ipv6,token,seperator); std::cout << token << std::endl; } } [/CODE] | |
Re: Try to first think out the logic of the problem without worring about coding it | |
Re: Rather than put raw pointers, a common technique is to use shared pointers, which use reference counting. Otherwise need to need to iterate and delete your own objects | |
Re: Get a few books on socket programming and start playing around. Two well know authors are W. Richard Stevens and Douglas E. Comer. ![]() | |
Re: Learn to think and design your programs in terms of real world concepts and use classes to express these ideas. | |
Re: Ok so start the debugger and step through the code. If you never used it before get someone to walk you through it... | |
Re: GOOGLE [url]http://www.codeguru.com/forum/showthread.php?t=360665[/url] You are probably compiling for multi-byte, is that what you really want? | |
Re: Are you expecting the above code to compile? | |
Re: You could create one thread as a service thread that calls the public methods of your objects every minute... | |
Re: probably good idea to check return codes for errors. For example if you are not able to open the file... | |
Re: If you are on windows, it probably in your trash, which you can restore. | |
Re: [url]http://stackoverflow.com/questions/4825030/c-add-to-linked-list-in-sorted-order[/url] | |
| |
Re: [CODE] template <typename Tdata> void q1_sort(vector<Tdata> &A, int left, int right) { if((right-left) < ISORT_CUTOFF){ if(data_t == 1) {in_sort<[COLOR="Red"]Tdata[/COLOR]>(A, (int)left, (int)right+1);} else if(data_t == 2) {in_sort<[COLOR="red"]Tdata[/COLOR]>(A, (int)left, (int)right+1);} } else{ q1_sort<[COLOR="red"]Tdata[/COLOR]>(A, left, i-1); q1_sort<[COLOR="red"]Tdata[/COLOR]>(A, i+1, right); } } [/CODE] | |
Re: alternatively, you might try using a vector of vectors vector< vector<int> > | |
Re: pseudorandom21 solution is clean and simple, spend some time to understand it [CODE] #include <iostream> #include <string> #include <sstream> int main() { std::stringstream strm("it your move"); std::string token; while(strm >> token) { std::cout << token << std::endl; } return 0; } [/CODE] | |
Re: Not clear what you mean by different memory address. Perhaps read each dataPY.bar into a different instance of a DataPY class? | |
Re: Should be fun, did an editor for debugger before with syntax highlighting etc. Try to design everything in terms of objects, should be good learning experiance. For example create a object model for your editor and implement using classes. | |
Re: When you hit a space, write it out then find all sebsequent spaces and throw them away. | |
Re: 1. First figure out how to do it by hand 2. Then search google to see how others have solved the problem 3. Finally write your program [url]http://www.indiastudychannel.com/projects/2080-C-Program-To-calculate-compound-interest-using-CI-P-R-T-P.aspx[/url] | |
Re: can you provide expression.h [url]http://msdn.microsoft.com/en-us/library/t8xe60cf(VS.80).aspx[/url] | |
Re: google c++ to php examples [url]http://stackoverflow.com/questions/705443/how-to-mix-up-c-and-php[/url] | |
Re: If its a cpu scheduler performance is probably important which implies perhaps a ring-buffer type structure might be useful Can you describe in more detail what you are trying to do? | |
Re: [CODE] int main() { int row = 10; int col = 4; // col of pointers to rows int **dynamicArray = new int *[col] ; // array for each row for( int i = 0 ; i < col; i++ ) { dynamicArray[i] = new int[row]; } // initialize with … | |
Re: GetTickCount() might give you what you want. [url]http://msdn.microsoft.com/en-us/library/ms724408(v=vs.85).aspx[/url] | |
Re: Rather than DayOfTheWeek.getDay, use getDay() Since you are calling a method of the class from withing the class | |
Re: In times of need, Google is your friend!!! [url]http://stackoverflow.com/questions/190229/where-is-the-itoa-function-in-linux[/url] | |
Re: [CODE] #include <iostream> #include <string> #include <sstream> int main() { std::stringstream expression(" 3 + 4 ( 5 * 8 "); std::string token; const char DELIMITER(' '); while (std::getline(expression, token, DELIMITER)) { std::cout << token << std::endl; } } [/CODE] | |
Re: You might want to consider to first break the problem into set of points (x,y). Then extract and convert each set of points to numbers. | |
Re: It would be good practice to always check your return codes. If you do so, you will most likely find your error. | |
Re: Yikes, is that really Andrew Koenig or a very good Impersonator!!! | |
Re: 1. Ofcourse newbies can learn C++!!! 2. Not a game programmer, but I suspect lots of games use c++ since performance is important 3. I use a mac at home, linux/windows at work. You already have everything you need. a. open a terminal window on your mac b. type nano … | |
Re: Interesing syntax, I thought array initialization has to be a constant??? Is'nt that going to go out of range and cause all kinds of interesing problems? since i is incremented further down... int i = 0; int sales[i]; | |
Re: Below is a example of one way to remove an item from a vector using an iterator. [CODE] class Eraser { public: Eraser() { _vector.push_back("fred"); _vector.push_back("alice"); _vector.push_back("billy"); } bool remove(const std::string &who_) { for( TVec::iterator i=_vector.begin(); i!=_vector.end(); ++i ) { if( *i == who_ ) { std::cout << who_ << … | |
Re: You are on the right track, below is sample of array using index and pointer. [CODE] #include <iostream> int main( int argc, char *argv[]) { const size_t LIMIT = 8; int buffer[LIMIT] ={0}; // array access using index notationn for(size_t i=0; i < LIMIT; i++) { buffer[i] = i; } … |
The End.