May 2002
Beginner
320 pages
6h 18m
English
An enumerated type is a data type whose variables can only take on a value from the set of constants listed in the type declaration (enumerated means “named one by one”). For instance, you can declare an enumerated type anOperator, and you can offer six possible values for it: add, subtract, multiply, divide, reset, and query (these are just like the Accumulator() operators).
The syntax for enumerated types is
enum{constantname,constantname...} ;
Here's an example:
enum anOperator {add,subtract,multiply,divide,reset,query} ;
This statement has two purposes:
It makes anOperator the name of a new type, and restricts it to having one of the six specified values, just as an int is restricted to having numbers without ...
Read now
Unlock full access