   clarification on the use of enumerators in c++
  high, i just want to clarify to see if i truly understand the use of enumerators before i put them in my game. so, tell me if im right!basically, i have a function called  bool Collide() and it checks if an entity has collided with a wall. if it has, it returns true, and if not, it returns false. NOW- lets say i implemented it so Collide() now checks if i collide not only with a wall, but checks if i collided with a monster. well now i cant have it be a bool function, because i want it to return 1 of 3 values, and theres no such as as true, false, and more false (or whatever). so i change it to Int Collide()now in this function is  saysif wall x,y == player x,y return 0;if open_space x,y == player,x,y return 1;if monster x,y == player,x,y return 2;now, this can get confusing seeing numbers, so what i did was #define 0 HIT_WALL#define 1 CAN_MOVE#define 2 HIT_MONSTERetc. now in a recent post i was told that defines are EVIL and i should not use these. so is this a good case to use enumerators? basically all they do is organize your numbers so your not looking at 0 or 1 or 2, your looking at HIT_WALL or CAN_MOVE, etc. it just makes things more clear. so am i right or what? and what else uses do enums have? thanks!!! 
  Yes.   edit: Beside being typed, enums have no other really interesting features. Some compilers will issue a warning if you forget some of the cases in a switch statement over an enum.“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor) [edited by - Fruny on February 3, 2004 3:56:36 PM];  Yes, enums would be very useful in that situation.  IMO they make code much more readable.;  Enums have one more advantage:They appear in the preprocessed code which makes it easier to autmatically generate wrappers for different programming languages. ;  Hello graveyard filla,I think enum can be used a a type in method params.in doing so you can never assign a enum a value which it does not belong.ie:enum { NO=0, YES=1, MAYBE=2 } what_t;int func(what_t w){...}w is of type what_t and can only be assign 0,1 and 2 if you try to assign a differnt number compiler should tell you about it. thoght I not sure what happens at run time.They have other features to which I can''t remember right now.Lord Bart ;  Correct idea, incorrect syntax. Here, what_t is a variable, of an anonymous enum type. enum what_t { NO, YES, MAYBE }; would be correct. Additionally, the compiler may only catch invalid enum parameters if they are known at compile-time. At run time, an enum parameter is an integer value like any other.   “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor);quote:#define 1 CAN_MOVE#define 2 HIT_MONSTERThat's not going to do what you think it will. It should be:#define CAN_MOVE 1#define HIT_MONSTER 2    quote:enum { NO=0, YES=1, MAYBE=2 } what_t;int func(what_t w){...}That doesn't do what you think it will, either. It should be:enum what_t {NO=0,YES=1,MAYBE=2};    orenum what_t {NO,YES,MAYBE};    The numbers weren't really necessary because you don't really use them.quote:w is of type what_t and can only be assign 0,1 and 2 if you try to assign a differnt number compiler should tell you about it. thoght I not sure what happens at run time.You can assign what_t any integer by casting it to what_t. The following compiled with g++:enum what_t {NO,YES,MAYBE}; //NO=0,YES=1,MAYBE=2int main(){   what_t t=NO;   what_t t=(what_t)10;   return 0;}    EDIT:30 seconds too late... Oh well, I still caught a mistake that he didn't get :D [edited by - brassfish89 on February 3, 2004 6:10:50 PM];  Using an enum means you don''t have to actually pick the numbers yourself. That lets you hide unimportant details while still using symbols to represent your results. But at the same time, if you''d rather have specific numbers assigned to your values in enum (e.g. because it lets you do arithmetic with the results), the syntax exists to do it. ;  enums can also be used for declaring static const members of a class, inside the class body, useful for doing template metaprogramming on compilers that don''t support static memmber initialisation inside the class body.you could doclass MyClass{   enum { N = 12345 };};which would be equivalent ofclass MyClass{   static const int N = 12345;};   