Angus Leeming wrote:

Michael Gerz <[EMAIL PROTECTED]> writes:
After having introduced the enum in the last two hours, I finally come to the conclusion that a simple bool type is more suitable than an enum type for which C++ does not provide any type-safety. There are just two values, on and off. That's what bool is made for

That's not true. The enum is perfectly type safe and is self-documenting,
something the enum isn't. Indeed, I'm pretty sure that one of those C++ gurus
(Meyers, Sutter, etc) recommends the use of enum over bool...
No, enum is NOT type-safe. I started with something like

  enum Tracking {
    on,
    off
  }

just to discover that a statement like

 if (tracking_changes) {
   ..
 }

still compiles - even though the bool variable turned in an enum (with on = 0). Not exactly nice...

For the moment, I will keep bool. Bother me later if this inaccaptable :-)

Michael

Reply via email to