Author: Russell Reagan
Date: 13:24:47 12/08/03
Go up one level in this thread
On December 08, 2003 at 15:48:31, Heiner Marxen wrote: >Is it just that C++ does not let you XOR enums without a cast? >(I do not do C++ myself, just C, so this may show my ignorance) > >What _is_ your point of using an enum? In C++, enums are a distinct type. For instance: enum Vowel { a, e, i, o, u, sometimes_y }; Vowel v; v = a; // fine v = 100; // compile time error v = Vowel(100); // fine The point of using an enum is so that I don't get erroneous values for a Color (or Piece, Square, etc.). If I go around bypassing the compile time checking, then there isn't much point and I should just use an int. It is basically just an extra thing to prevent me as the programmer from doing something stupid, but I quit using this approach because I didn't like having to bypass this stuff to achieve optimal efficiency. Now I just use well placed assert()'s in an attempt to make sure my data doesn't have erroneous values.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.