Next: Pointers and Arrays Up: Introduction to C++ Previous: Unions

Enumeration Types

An enumeration type allows one to give a type definition to a collection of objects. The declaration gives a name to the type, along with a list of acceptable values for the type. One may subsequently define variables of that type, and make assignments or comparisons to objects in the set.


enum month {jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec};
month procmonth1, procmonth2;
procmonth1 = jul;
procmonth2 = procmonth1;
...
if (procmonth2 == jan) ...


walter@
Wed Aug 10 11:53:26 PDT 1994