Enumeration

An Enumeration is a user-definable, integral type. An enumeration is defined using the enum keyword. A range of values and a name for these values are also defined the same time.

Example:
enum Shape{Line,Rectangle,Ellipse};
1.Example for Enumeration:

#include <iostream> 
using namespace std; 
enum week { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,Sunday }; 
int main() 
{ 
week day; 
day = Friday; 
cout << "Day: " << day+1<<endl; 
return 0; 
} 
Output:
Day: 5
Translate »