Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我们有以下声明
enum visibility { On = 0, Off = 1, maxVisibility };
C++11/C++0x中maxVisibility枚举器的保证值是标准的吗?2
maxVisibility
2
是的,这是有保证的。
§ 7.2.2
如果第一个枚举器没有初始化器,则相应常量的值为零。没有初始化器的枚举器定义为枚举器提供了通过将前一个枚举器的值增加 1 获得的值。