When does C++ specify the enumeration value
The main content of this article is "when does C++ specify the enumeration value", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn when C++ specifies the enumeration value.
Enum.8: specify enumerated values only if necessary
Reason (reason)
It's the easiest way. Duplicate enumerated values can be avoided. By default, a set of continuous values is assigned that can be easily used by switch statements.
Example (sample)
Enum class Col1 {red, yellow, blue}
Enum class Col2 {red = 1, yellow = 2, blue = 2}; / / typo
Enum class Month {jan = 1, feb, mar, apr, may, jun
Jul, august, sep, oct, nov, dec}; / / starting with 1 is conventional
Enum class Base_flag {dec = 1, oct = dec