- Example
In the follwoin example, we will go over the implementation of Enumerations.
We'll cover the following
Example
We can explicitly specify the type of enumerators. By default, it’s int
however, we can change the type being used.
We can use integral types such bool
, char
, short int
, long int
, or, long long int
. Read msdn.microsoft.com for the details. Read the post Check types to see as to how we can check at compile time if a type is integral.
We can independently use the scoped property and the explicit type specification of an enumeration. Dependent on the base types, the enumerations have different sizes.
Below is an example of the implementation of scoped enumerations using struct
and class
.
Get hands-on with 1400+ tech skills courses.