Try this habit (where input is the variable and EXPECTED_VALUE is a const
1 2 3 4
if( EXPECTED_VALUE == input)
{
// ...
}
instead of
1 2 3 4
if( input == EXPECTED_VALUE)
{
//...
}
in order to avoid errors like this one
1 2 3 4 5
if( input = EXPECTED_VALUE)
{
// will always execute this block since assignment operator used
// accidentally. The compiler will catch this if the const is on the LHS
}
20: buy and read C++ Coding Standards: 101 Rules, Guidelines, and Best Practices By Herb Sutter, Andrei Alexandrescu. Or other books along these lines...there will probaby be some suggesting posted after this... :0)