Home Segments Index Top Previous Next

486: Sidetrip

A more general form of the enumeration statement allows you to create enumeration data types. These new data types allow you, in turn, to create enumeration variables.

The following statement, for example, makes car_code an enumeration data type and assigns values to four enumeration constants:

enum car_code {eng_code, box_code, tnk_code, cab_code}; 

Subsequently, you can declare particular variables to be car_code variables by using the two symbols enum car_code as a data type. The following, for example, makes c a car_code variable:

enum car_code c;