Do C++ enums Start at 0?

后端 未结 3 1738
猫巷女王i
猫巷女王i 2020-12-03 04:07

If I have an enum that does not assign numbers to the enumerations, will it\'s ordinal value be 0? For example:

enum enumeration { ZERO,
                


        
3条回答
  •  没有蜡笔的小新
    2020-12-03 04:56

    from § 7.2, p 165

    . If the first enumerator has no initializer, the value of the corresponding constant is zero

    source: http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4527.pdf

提交回复
热议问题