Next: Static Variables Up: Further Data Types Previous: Coercion or Type-Casting

Enumerated Types

Enumerated types contain a list of constants that can be addressed in integer values.

We can declare types and variables as follows.

~enum days {mon, tues, ..., sun}week;

~enum days week1, week2;

NOTE: As with arrays first enumerated name has index value 0. So mon has value 0, tues 1, and so on.

week1 and week2 are variables.

We can define other values:

We can also override the 0 start value:

~enum months {jan= 1, feb, mar, ......, dec};

Here it is implied that feb = 2 etc.
Fri May 20 13:40:49 BST 1994