Next: , Previous: Built-in datatypes, Up: Datatypes


7.2 Enumerations

Enumerations are sets of values associated with user-specified names. The value members of an enumeration represent a set of logical values that only have meaning in the enumeration's context, i.e. they are not publicly observable values. (This is unlike C, in which enumerations can take integer values that can be passed to and from integer variables.) Enumerations are particularly useful for specifying control and data interfaces between communicating processes. Think of enumerations as tags that can be understood by the sender and receiver of the enumerated type.

The only values that an enumerated instance can take are those specified in the enumerated type. Thus one can never assign an integer or boolean value to an enumeration, nor can one assign an enumerated value to an int or \bool\ or other user-defined type. One can only compare enumerated values of the same enumerated type.

There is no notion of equivalence between enumerated types (outside of typedefs, Typedefs).