The constants in an enum
are represented as integers. By default, an unscoped enum
’s underlying integral type depends on its constants’ values—the type is guaranteed to be large enough to store the constant values specified. By default, a scoped enum
’s underlying integral type is int
. C++11 allows you to specify an enum
’s underlying integral type by following the enum
’s type name with a colon (:
) and the integral type. For example, we can specify that the constants in the enum class Status
should have type unsigned int
, as in
enum class Status : unsigned int { CONTINUE, WON, LOST };
18.222.196.175