View Single Post
  #5   Spotlight this post!  
Unread 26-01-2005, 20:23
jdong jdong is offline
Linux Nerd
AKA: John D
#0245 (Adam-Bots)
Team Role: Programmer
 
Join Date: Apr 2004
Location: Rochester, MI
Posts: 98
jdong will become famous soon enoughjdong will become famous soon enough
Re: Weird problem with if statements

Someone who's studied C++ Operator Overloading could tell you that the equals operator has similar to the following declaration:

int & operator=(int & left_hand_side, int & right_hand_side)

That is, the assignment operator returns a reference to the assigned value, allowing chaining (I think a better term) of assignments. As long as you assign a non-zero number, this statement will evaluate to TRUE. Definitely not the behavior you want....

Good for cheats, like assigning a NULL pointer within an IF statement would return FALSE, causing the block of code to be skipped. Good for experts, nightmare for beginners.
__________________
John Dong
Co-Captain, Webmaster / Programmer
Team 245 -- Rochester Adams Robotics