August 2012
Intermediate to advanced
976 pages
30h 17m
English
Enumerations let us group together sets of integral constants. Like classes, each enumeration defines a new type. Enumerations are literal types (§ 7.5.6, p. 299).
C++ has two kinds of enumerations: scoped and unscoped. The new standard introduced scoped enumerations. We define a scoped enumeration using the keywords enum class (or, equivalently, enum struct), followed by the enumeration name and a comma-separated list of enumerators enclosed in curly braces. A semicolon follows the close curly:
enum class open_modes {input, output, append};
Here we defined an enumeration type named open_modes that has three enumerators: ...
Read now
Unlock full access