gpt4 book ai didi

c++ - 错误 : 'enumElement' was not declared in this scope

转载 作者:太空宇宙 更新时间:2023-11-03 10:25:01 24 4
gpt4 key购买 nike

我写了下面的小脚本:

#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
enum class Day {sunday, monday, thuesday, wednesday, thursday, friday, saturday};
Day unusedDay, today = sunday;
}

但是我有一个问题。当我调试程序时,编译器说:

error: 'sunday' was not declared in this scope

但是有我的枚举类。为什么不宣布星期日?我该如何改变它?

感谢您的回答:)

最佳答案

Day unusedDay, today = Day::sunday;

枚举数在枚举范围内。

关于c++ - 错误 : 'enumElement' was not declared in this scope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39317752/

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