|
Re: Weird problem with if statements
That sort of makes sense. After all, jdong shows how it can be represented with operator overloads and reference returns, yet C doesn't allow reference types. Just shows how easy it is to take C++ for granted.
By the way, I remember reading somewhere that NULL (or any literal '0', since NULL is a macro) is not guaranteed to evaluate to 'false' for all implementations. This means that you may not get the result you expect when you do "if(ptr)" to test if a pointer is safe to dereference. Or maybe I have it reversed, and it's something related that isn't guaranteed... Oh well, just be careful with your if conditions.
|