It's actually a technique that I saw used in MFC programming. The compiler messages in C# are pretty good and usually catch you leaving one of the equals-signs off. In straight C++, the compiler usually doesn't tell you unless the datatypes on both sides are different (in which case you need to be doing a cast anyway). So you end up coding an assignment instead of a comparison, and you don't find out until runtime (uh-oh!).
So, by putting the constant value (if any) on the left-hand side of the comparison operator, you protect yourself against typos.
Chip H.
If you want to get the best response to a question, please check out FAQ222-2244 first
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.