
128 C++ Declarations
Enumerated Data Type
The enum is a keyword. It is used for declaring enumeration data types. The programmer can
declare new data type and define the variables of these data types that can hold. For example,
the user can define the material as new data type. Its variable may be solid, liquid, and gas. Thus
the three values are restricted for this new data type. These enumeration data types are useful in
switch() case statement.
The syntax for enumerated data type is as follows and it uses a keyword enum.
enum logical { false,true};
enum logical {true=2, false=4};
enum components{solid,liquid,gas};
This statement declares a user-defined ...