August 2001
Beginner
482 pages
10h 52m
English
Enumerated constants create a set of constants. For example, you can declare COLOR to be an enumeration; and you can define that there are five values for COLOR: RED, BLUE, GREEN, WHITE, and BLACK. |
The syntax for enumerated constants is to write the keyword enum, followed by the type name, an open brace, each of the legal values separated by a comma, and finally a closing brace and a semicolon. Here's an example:
enum COLOR { RED, BLUE, GREEN, WHITE, BLACK };
This statement performs two tasks:
It makes COLOR the name of an enumeration, that is, a new type.
It makes RED a symbolic constant with the value 0, BLUE a symbolic ...
Read now
Unlock full access