Department of Engineering

IT Services

Enumerated types

When a small set of values is needed to represent a non-numeric quantity, an enumerated type can be declared, e.g.:

   enum Days {Mon, Tue, Wed, Thu, Fri, Sat, Sun};
   Days today = Tue;

creates a new variable type with legal values Mon, Tue, Wed, Thu, Fri, Sat, Sun. Variable today is initially assigned the value Tue, and the compiler will ensure that only values in the range Mon to Sun may be assigned to today.