|
enum
Syntax:
enum name {name-list} var-list;
The enum keyword is used to create an enumerated type named name that consists of the elements in name-list. The var-list argument is optional. For example, the following code creates an enumerated type for colors: In the above example, the effect of the enumeration is to introduce several new constants named red, orange, yellow, etc. By default, these constants are assigned consecutive integer values starting at zero. You can change the values of those constants, as shown by the next example: When executed, the above code will display the following output: |