I was going through some VC++ code in a large code-base and came across this:
if (nState & TOOL_TIPS_VISIBLE)
nState &= ~TOOL_TIPS_VISI
What hasn't been mentioned is that both &=
and |=
operators can be overloaded. Therefore, the code you posted depends on the type of nState (although it's quite clearly an int, so most probably this doesn't apply here). Overloading &=
does not implicitly overload &
, so in this case
x &= y might not be the same as x = x & y
It might also depend on what TOOL_TIPS_VISIBLE
is.
struct s{
int x;
};
void operator &= (int& x, s y)
{
x = 0;
}
Now whenever you do:
s TOOL_TIPS_VISIBLE;
x &= TOOL_TIPS_VISIBLE;
x
will become 0
. Again, highly unlikely, but good to know nevertheless.
All other answer probably apply here, but this is worth considering.