Is it because cat.GetInto is in a class? I've never read about this before...Code:if(cat.GetInfo() = 0) { return 0; }
Is it because cat.GetInto is in a class? I've never read about this before...Code:if(cat.GetInfo() = 0) { return 0; }
It's supposed to be:
cat.GetInfo() == 0.
== is comparison operator
= is assignment operator
That's right! Math got to be again. Stupid me (again!). Thanks.
Hehe, I abhor those types of errors, so simple yet alter the program totally.
Too bad the compiler doesn't have an option to automatically fix them.
Actually, if you use gcc with the -Wall option, it will issue warnings for this:
Code:int main() { int i = 0; if(i = 50) ; return 0; }
$ g++ -Wall test.cpp
test.cpp: In function `int main()':
test.cpp:6: warning: suggest parentheses around assignment used as truth value
Sometimes you'll find people reverse the operands so that the compiler catches it, for instance in this case:
compiles fine, whereas:Code:if(0 == cat.GetInfo()) { return 0; }
should throw up a compilation error. That said, the argument goes, if you can remember to reverse the operands, you can remember to check for correct use of the equality operatorCode:if(0 = cat.GetInfo()) { return 0; }