Enumeration in C++
Enumeration in C++ An enumeration is a user-defined data type that consists of integral constants. To define an enumeration, keyword enum is used. enum season { spring, summer, autumn, winter }; Here, the name of the enumeration is season . And, spring , summer and winter are values of type season . By default, spring is 0, summer is 1 and so on. You can change the default value of an enum element during declaration (if necessary). enum season { spring = 0, summer = 4, autumn = 8, winter = 12 }; Enumerated Type Declaration When you create an enumerated type, only blueprint for the variable is created. Here's how you can create variables of enum type. enum boolean { false, true }; // inside function enum boolean check; Here, a variable check of type enum boolean is created. Here is another way to declare same ...