Hi,
Can oneone explain clearly what the c++ enum data type below:
enum {OFF = 1, ON = 2, RUN = 4, SHUTDOWN = 5};
With no name tag, what the the code mean?I have'nt seen like
this kind of data define before!
Thanx!
Sunset
Hi,
Can oneone explain clearly what the c++ enum data type below:
enum {OFF = 1, ON = 2, RUN = 4, SHUTDOWN = 5};
With no name tag, what the the code mean?I have'nt seen like
this kind of data define before!
Thanx!
Sunset
Hi,
If you are planning to use just constants and not create variables of the enumerated type, you can omit the an enumeration type name.
Mr. C
Enum makes it easier to understand your code. Instead of typing this:
You should make an enum like this:Code:int WalkingDirection; WalkingDirection = GetPressedKeyDirection(); switch(WalkingDirection) { case 0: Xpos++; break; case 1: Xpos--; break; case 2: Ypos++; break; case 3: Ypos--; break; }
It makes the code sooo much easier to read/understand.Code:typedef enum { RIGHT, LEFT, UP, DOWN }DIRECTION; DIRECTION WalkingDirection; WalkingDirection = GetPressedKeyDirection(); switch(WalkingDirection) { case RIGHT: Xpos++; break; case LEFT: Xpos--; break; case DOWN: Ypos++; break; case UP: Ypos--; break; }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Or like this:
Code:enum DIRECTION { RIGHT, LEFT, UP, DOWN };
Couldn't think of anything interesting, cool or funny - sorry.