Home Segments Index Top Previous Next

435: Sidetrip

Whenever you assign an enumeration variable, the right side of the assignment expression should be an enumeration constant of the same type. The following, for example, is appropriate, given that c is a industry_code enumeration variable:

c = food; 

Some compilers warn you if you assign any object other than an enumeration constant to an enumeration variable. Using one of these compilers, you will get a warning if you write the following assignment statement:

c = 0;