... Status
(line 18). Line 12 declares a user-defined type called a scoped enumeration (C++11) which is introduced by the keywords enum class
, followed by a type name (Status
) and a set of identifiers representing integer constants. The values of these enumeration constants are of type int
, start at 0
(unless specified otherwise) and increment by 1
. In the preceding enumeration, the constant CONTINUE
has the value 0, WON
has the value 1 and LOST
has the value 2. The identifiers in an enum class
must be unique, but separate enumeration constants can have the same integer value. Variables of user-defined type Status
can be assigned only one of the three values declared in the enumeration.
Good Programming Practice 6.2
By convention, you should capitalize ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.