|
An Enumeration is a user defined integer type which provides a way for attaching names to numbers, thereby increasing the comprehensibility of the code. The enum keyword automatically enumerates a list of words by assigning them values 0,1,2 and so on. When you declare an enumeration, you specify a set of acceptable values that instance of that enumeration can contain. Not only that, but you can give the values user-friendly names. If, somewhere in your code, you attempt to assign a value that is not in the acceptable set of values to an instance of that enumeration, the compiler will flag an error. Eg.
enum shape{
Circle,
Square,
Triangle }
this can be written in one line as follows:
enum shape { Circle, Square,Triangle }
|