Using Enumerations in C++
By admin on May 24, 2009 in Working with C++
Enumerations in C++ work in a similar manner to other languages, to restrict a particular variable to having a specific set of values.
For example:
enum Names {Fred, Mary, John, Anne}
In this case, a new type is created, which may have <b>only</b> the values Fred, Mary, John, Anne.
The compiler will represent Fred as 0, Mary as 1 and so on. John will take the next value, which here will be 2.
Sorry, comments for this entry are closed at this time.