所以我试图学习枚举类。我从我的书中复制了这段代码:Enum类只能用于-std = C++ 11
#include <iostream>
using namespace std;
int main()
{
enum class Color
{
RED,
BLUE
};
Color color = Color::RED;
if (color == Color::RED)
cout << "The color is red!\n";
else if (color == Color::BLUE)
cout << "The color is blue!\n";
return 0;
}
我希望代码打印出“The Color is red!”。 然而,我的编译器会发出此错误:
warning: scoped enums only available with -std=c++11 or -std=gnu+11
和
error:'Color' is not a class or namespace
我目前使用开发 - C++ 5.11。任何想法如何解决这个问题?
请在帮助中心阅读有关MCVE的信息。 – philipxy
什么是“Dev-C++ 11”? –
Dev-C++是一个免费的Windows IDE,它使用MinGW或TDM-GCC作为底层编译器。 –