c++ - 枚举变量的默认值是多少?

标签 c++ c enums

我对 C++ 中的枚举变量有疑问:

type enmu {
   DAY1 = 1,
   DAY2,
   DAY3,
   DAY4
} DAYS;

void main() {
   DAYS days;
}

那么天数的默认值是多少?

最佳答案

读取值是未初始化和未定义的行为

就像说

int x;

x 在您初始化之前没有值。

关于c++ - 枚举变量的默认值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12037604/

相关文章:

c - 我应该如何将此整数数组传递给这个函数?

Groovy 枚举 : switch statement throws error before running relating to static

c++ - Windows 转储文件 (hdmp) - 没有 pdb 文件的信息

c - 逐行读取文件 - 文件在哪里?

C++ undefined reference

c++ - 使用 "if (var = 0 || var == 0)"语句将 var 更改为 1

c++ - 枚举 header 多个定义

c++ - "negation of enumeration"是什么意思?

c++ - 将 blender 模型导入 DirectX 11.2 C++ 应用程序

c++ - 如何创建一个包含其类型未知的值的类?