- Strength to Increase Rep
- +3
- Strength to Decrease Rep
- -0
- Upvotes Received
- 4
- Posts with Upvotes
- 4
- Upvoting Members
- 4
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Re: How about using cin.get() to get one character at a time, verifying that the order is digit, digit [convert to int and check range], colon, digit, digit [convert to int and check range], end-of-line. Maybe ignore leading or trailing white space to be nice. Not sure how you're going to … | |
Re: [QUOTE=the great;1037809]Hello ... It is not taking the inputs of name and address as it should. Got confused how to solve it. [/QUOTE] After the [ICODE]operator>>()[/ICODE], the input is left pointing at the end-of-line character. At the next call of [ICODE]get()[/ICODE], there is already input available (the end-of-line character), so … | |
Re: I can't see an obvious explanation for why your second cout statement doesn't print anything. However, one flaw in this function is that the args[] and args1[] arrays must end with a 0 as their last element (a Unix requirement, not a C++ one) -- otherwise how does execvp() know … | |
Re: [QUOTE=nick30266;1037878]can somebody help me with this program?? [...] find a path moving like a knight in chess game(L) that touch every point of the matrix once. ...[/QUOTE] Head start: from the current position, make a list of all the possible next moves that go to a position that hasn't been … | |
Re: Association can have lots of meanings. Any reference from one class to another is a kind of association. "Has-a" is one; it could also be "uses." "Has-a" is often called aggregation or composition. In terms of C++; it's commonly implemented by a member variable of the owned type, or by … | |
Re: appt.subject is a char*. What does it point at? Abandon char* and use std::string. | |
Re: The most direct way, since you've already included the algorithm header, is to use std::sort(). | |
Re: Just guessing here, but rethink your break statements. Maybe you want to reorganize to find the matching ID, then break out of the loop and finish the location lookup. [code] bool found = false; for ( int c = 0; c < student_max ; ++c ) { if ( search_id … | |
Re: You can return entire structures from functions. [CODE] Compass getCompass() { Compass result; result.C = make_pair(3,4); // etc. return result; } void someFunction() { Compass V = getCompass(); int j = V.C.first; // ... } {[/CODE] | |
Re: At line 6, you declared showMedian to take a double parameter, but you implemented it to take a double *. At line 84, are you trying to call arrSelectSort again? If so, it doesn't need the types in its arguments. At line 90, you are checking a pointer to see … | |
Re: Couple o' things: Search has to return a pointer, so don't return info, return the pointer of the node you're looking at. The recursive call of Search() has to take the same parameters as the first call, so don't forget to pass key. That while loop at the end of … | |
Re: [code=syntax] std::string s; // ... code that reads from file into s ... if ( s.find("xxx") != std::string::npos ) [/code] | |
Re: [QUOTE=sciwizeh;844061] Hello, I have a question, when does a global variable get destructed? [/QUOTE] The compiler arranges for code to get executed both before main() is called and after it returns. Before main(), global constructors are called. After main(), global destructors are called in opposite order of their construction. | |
Re: > Hello, bool Set::operator==(const Set& b) const { if(b.header <= header && header <= header) //codes.... return true; } > Inside my overload for == which I use <= it doesn't use my overloaded version of <= instead it uses the standard version. Do I have to write a certain … | |
Re: For the purpose of sorting, any complete ordering will do. You could define a sort that uses x as primary key, y as secondary, and z as tiebreaker. [code] // Comparator function object to define less-than for Points struct PointLess { bool operator()(const Point& p1, const Point& p2) const { … | |
Re: You declared alpha and beta as int instead of an array in the function definition. | |
Re: Another use is to hold a collection of heterogeneous objects. For instance, if you have the classic example of things derived from Shape (triangle, circle, etc). If you make an array of Shape objects, then they are just base objects (not triangle etc). But if you make it an array … | |
Re: You need a blocking call that waits for input. Look up the select() system call. |