View Single Post
Old Oct 6th, 2005, 7:46 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,209
Rep Power: 5 grumpy is on a distinguished road
The issues with booleans (defining the acceptable values, defining the name of the type, etc) are one of the reasons that C++ supports the bool type and true/false keywords.

In the examples above I would not bother with "#define true !false" or "enum bool {false, true};". Simpler forms that achieve exactly the same things are "#define true 1" and "enum bool {false, true};" respectively.

The main problems with such techniques come in if you're reusing other people's code. There are many possible variants of this sort of scheme: using such techniques, no matter what you do, you will encounter some code that breaks because of mixing and matching two techniques.
grumpy is offline   Reply With Quote