We have defined a new type with a specified set of values. To assign values of that type to a variable, we now have to define a variable using our new enumerated type.
Declaring a variable of type enum suit would be done as follows:
enum suit card;
...
card = spade;
...
if( card == club ) ...
else if( card == diamond ) ...
else if( card == heart ) ...
else if( card == spade ) ...
else
printf( "Unknown enumerated value\n" );
Since card is an enumerated type, it cannot take any value other than those specified in the type. To do so would cause a compiler error. You will notice in the preceding code snippet that we check for any enumerated value outside of our known set of values. This is actually not required for a simple card suit example; is there a deck of cards with more than 4 suits? I think not. Is it likely then, that our set of enumerations would change? Also not likely. Furthermore, card as an enumerated type...