Forum: C++ Oct 8th, 2009 |
| Replies: 4 Views: 236 atoi(text[0]) will not work because atoi expects a char*, not a char. That half of NeoKyrgyz's answer was basically useless and dumb.
If you want to convert the character "c" representing the... |
Forum: C++ Mar 13th, 2009 |
| Replies: 10 Views: 629 You want to calculate the n-term series and not the infinite series? |
Forum: C++ Mar 13th, 2009 |
| Replies: 14 Views: 760 Your "line equation" is wrong -- you have defined a point. |
Forum: C++ Mar 12th, 2009 |
| Replies: 10 Views: 629 In that case, the right solution would still be to use the closed form expression :) |
Forum: C++ Mar 12th, 2009 |
| Replies: 10 Views: 629 Well it's almost like the series for exp(x), except the signs are alternating and it's missing the x^1 term and the x^0 term has the wrong sign. If consider the series you get for exp(-x), you... |
Forum: C++ Mar 10th, 2009 |
| Replies: 1 Views: 359 You want a struct with a double and a bool.
You should never use inheritance except as a mechanism for polymorphism -- one reason being that 'putting stuff into structs' or classes (a.k.a.... |
Forum: C++ Feb 26th, 2009 |
| Replies: 6 Views: 1,092 Maybe I'm not being very clear. I'm saying, suppose your class began with the following:
class dequeint {
private:
NodeType NodeArray[MAXSIZE];
int headi; // index of first... |
Forum: C++ Feb 24th, 2009 |
| Replies: 6 Views: 1,092 Maybe some thinking would work, too. |
Forum: C++ Feb 23rd, 2009 |
| Replies: 6 Views: 1,092 This: ((tailsucci+1)%MAXSIZE) !=headi is wrong.
Figure out why.
One problem you have is that if tailsucci and headi are both equal, you can't tell whether the buffer is full or empty. You... |
Forum: C++ Feb 21st, 2009 |
| Replies: 6 Views: 788 What the **** is wrong with you? The mechanism for creating datatypes in C++ is classes. Why wouldn't you use classes?
In the future, please keep your insanity to yourself. The insanity isn't... |
Forum: C++ Feb 6th, 2009 |
| Replies: 4 Views: 372 The danger lurks because the pointer could be null, or the pointer could be pointing at something that no longer exists. It's easy for programmers to make mistakes like that. It's slightly harder... |
Forum: C++ Feb 5th, 2009 |
| Replies: 4 Views: 372 It's the same thing -- once the code has been compiled -- and used for the same purpose. It's better to use the second way, passing "by reference," because the first desensitizes you toward... |
Forum: C++ Feb 5th, 2009 |
| Replies: 5 Views: 383 |
Forum: C++ Feb 3rd, 2009 |
| Replies: 2 Views: 509 It makes a copy of the string. For it not to do so would be counter-intuitive -- if it wanted a pointer to a string, it would ask for one.
In particular, you'll note that the constructor takes a... |
Forum: C++ Feb 1st, 2009 |
| Replies: 2 Views: 264 Where you wrote ostream &Month::operator<<(ostream &strm, const Month &obj), you should be writing ostream &operator<<(ostream &strm, const Month &obj). The function you're defining is not declared... |
Forum: C++ Feb 1st, 2009 |
| Replies: 7 Views: 450 The reason is that blah = 1 sets the lvalue blah to 1. You want blah == 1, which evaluates to true if blah is 1. It's generally a good idea in C++ to get in the habit of putting constants like 1 on... |
Forum: C++ Jan 30th, 2009 |
| Replies: 6 Views: 1,095 Why do you have a class named Swap? |
Forum: C++ Jan 29th, 2009 |
| Replies: 3 Views: 608 Flow charts are basically an awful way to design a program and an awful way to represent the design of a program. If you asked me to name any "good" ways to _represent_ the design, I couldn't. But... |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 1,427 Yes, we know what a static variable is.
I have no clue what you're talking about. |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 1,427 A better solution would just to make that variable a member of the class. Yours would require extra code to check that the same class is receiving the call as before. And it wouldn't be thread... |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 1,427 The ability to have static variables in the middle of functions is a crufty feature left over from the old days of C. |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 1,427 I'm guessing it would just act like a static variable. I wouldn't make use of it at all -- put any static constants you have in your class definition and don't use static variables. |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 1,427 Why do you say static variables will be disposed of at the end of the function call? |
Forum: C++ Jan 27th, 2009 |
| Replies: 10 Views: 680 Well it seems you didn't read my reply, so never mind. |
Forum: C++ Jan 27th, 2009 |
| Replies: 10 Views: 680 What the ****? Your random function isn't random any more. |
Forum: C++ Jan 27th, 2009 |
| Replies: 3 Views: 306 Your problem is that you're recreating the file every time through the loop. Thus, the old data gets replaced. |
Forum: C++ Jan 27th, 2009 |
| Replies: 8 Views: 604 One reason you can't just "catch and handle" pointer errors is that if you overwrite something in the wrong place of memory, it can totally screw with the behavior of your program. You could have... |
Forum: C++ Jan 27th, 2009 |
| Replies: 8 Views: 604 Using pointers directly is undesirable because pointers are dangerous. If you have a pointer, the thing it's pointing to could become destroyed, so you have to make sure that hasn't been done. ... |
Forum: C++ Jan 26th, 2009 |
| Replies: 8 Views: 604 Well, error catching is what try-catch blocks are for...
But if you're talking about some pointer-related bug, the right answer is to avoid using pointers directly in the first place. I don't... |
Forum: C++ Jan 26th, 2009 |
| Replies: 10 Views: 680 Hm yes, VernonDozier identified what was actually causing your problem. Fix your random function, too, though. |
Forum: C++ Jan 26th, 2009 |
| Replies: 10 Views: 680 Your function random is broken! This is an awesome bug. It's broken in two ways.
First, it's broken because rand() may return RAND_MAX. In such a case, your random function is clearly broken,... |
Forum: C++ Jan 26th, 2009 |
| Replies: 13 Views: 978 Also, it's important to delete them because they might have other stuff to do (like flushing data to filehandles, and such). |
Forum: C++ Jan 26th, 2009 |
| Replies: 13 Views: 978 It doesn't remain "in memory" because the process has completed and all of its memory is reclaimed by the operating system. |
Forum: C++ Jan 26th, 2009 |
| Replies: 13 Views: 978 What the **** are you talking about? When the program ends, nothing remains. |
Forum: C++ Jan 26th, 2009 |
| Replies: 3 Views: 459 Header files typically contain declarations of functions, not their definitions. Typically, the implementations are placed in a similarly named cpp file. Your project will then have multiple cpp... |
Forum: C++ Jan 26th, 2009 |
| Replies: 3 Views: 459 This is absolutely awful. Do not do what you are talking about doing.
Tell us what your problem is, what you really are trying to achieve, instead of asking about one particular mechanical... |
Forum: C++ Jan 26th, 2009 |
| Replies: 10 Views: 1,200 Maybe this is a stupid question, but why you writing myvector->push_back(...) instead of myvector.push_back(...)? myvector is a cliext::vector<T>, not a cliext::vector<T>^. |
Forum: C++ Jan 25th, 2009 |
| Replies: 10 Views: 1,200 C# is easy to learn, and unless you have a very specific, articulable reason to be using C++/CLI, you would be better off going with C#.
Edit: Also, don't expect an answer here; your question is... |
Forum: C++ Jan 25th, 2009 |
| Replies: 6 Views: 403 Yes, you can make your own class that inherits from ostream. |
Forum: C++ Jan 24th, 2009 |
| Replies: 5 Views: 368 Why don't you just learn both? |