gpt4 book ai didi

c++ - 未初始化的枚举器默认值

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:15:30 25 4
gpt4 key购买 nike

假设我们有以下声明

enum visibility
{
On = 0,
Off = 1,
maxVisibility
};

C++11/C++0x标准中maxVisibility枚举数2的保证值是?

最佳答案

是的,这是有保证的。

§ 7.2.2

If the first enumerator has no initializer,the value of the corresponding constant is zero. An enumerator-definition without an initializer gives the enumerator the value obtained by increasing the value of the previous enumerator by one.

关于c++ - 未初始化的枚举器默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18868599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com