Enumeration Types

Pascal allows definition of sets of names as an ordered scalar type.

   type color = (red, white, blue);

Having defined this type, we can use it:

   var flag: color;

Pascal defines type boolean = (false, true).

C++ has a similar construct:

   enum color {red, white, blue};

Java allows constants to be defined within a class:

class Color {
   final static int RED = 0;
   final static int WHITE = 1;
   final static int BLUE = 2; }
These constants are accessed as Color.RED etc.

Contents    Page-10    Prev    Next    Page+10    Index