[prev] [index] [next]

Enums

Enumerated types (enums) ...
  • define a new data type by listing its values (names)
  • specify an ordering on the values
  • associate the values (names) with ints
Example:

enum Mood { depressed, sad, well, happy };

is equivalent to the definitions:

#define depressed 0
#define sad       1
#define well      2
#define happy     3

and a new type  enum Mood  which is effectively unsigned int.