Symbolic constants

Symbolic integer constants can be defined with the traditionnal enum declarator.

enum numbers { one=1, two, three } ;
or
typedef enum  { peugeot=1, renault=2, citroen=4, other } cars ;

In these examples, values of one, two, three are respectively 1,2 and 3, and values of peugeot, renault, citroen and other are respectively 1, 2, 4, and 5.

Remember that constant defined with enum are ints, so the specified values must range from -128 to 255 (255 and -1 being in fact the same constant).



AG 2013-04-10