The enumeration type allows us to specify a set, or group, of values a variable may have, and only those values. Any assignment of a value outside of that range/group would be a compiler error. The compiler catching such an error rather than it being caught at runtime is preferred since it prevents unexpected program crashes.
The syntax for defining an enumerated type is as follows:
enum name { enumeration1, enumeration2, … , enumerationN };
The type consists of the two words, enum and name. The group of enumerated items is contained within { and }. Each named item in the group of enumerated items is separated by , and the definition is concluded with ;.
So, the definition of our enumerated type of suit would be as follows:
enum suit { spade , heart , diamond , club };
Or, we might want to make each item stand on its own, as follows:
enum suit {...
spade ,
heart ,
diamond ,
club
};