Only explicit conversions are possible for converting to (from) any integer type (not char, though) from (to) an enum type by using the cast operator (<Type>). However, the number 0 (zero) is an exception. It can be implicitly converted to an enumerator type; the reason is displayed in the Tip box.
It is also possible to explicitly convert one enumerator type to another enumerator type.
Tip
The only numeric value that can be implicitly converted to an enumerator type is 0. To reset or initialize an enumeration variable is the equivalent of assigning it the first member of the enumeration. If the first member of any enumeration is always set to have the value 0, it's possible to utilize the value 0 when initializing an enumeration. For example to initialize currentDay, we can simply write currentDay = 0; Therefore, always define one of the members of the enumeration to represent the value 0. |