Enumeration in C++
Enum is
a user defined data type where we specify a set of values for a variable and
the variable can only take one out of a small set of possible values. We use
enum keyword to define a Enumeration.
Syntax:
enum
enumerated-type-name{value1, value 2, value N};
Example:
enum
direction{east ,west, south, north} dir;
Program:
#include<iostream.h>
#include<conio.h>
enum
direction{east ,west, south, north} dir;
void
main()
{
dir=west;
cout<<dir;
getch();
}
Output:
1
No comments:
Post a Comment