Enumeration, or enum for short, is a type whose values are symbolic, user-defined, named constants called enumerators.
There are two kinds of enums: the
unscoped enums and
scoped enums. The unscoped enum type can be defined with
enum MyEnum
{
myfirstvalue,
mysecondvalue,
mythirdvalue
};
To declare a variable of enumeration type
MyEnum, we write
enum MyEnum
{
myfirstvalue,
mysecondvalue,
mythirdvalue
};
int main()
{
MyEnum myenum = myfirstvalue;
myenum = mysecondvalue; // we can change the value of ...