C++(11):枚举类_风静如云的博客-CSDN博客_c++11 枚举类
介绍了枚举类使用的好处。
不过如果直接输出枚举类的值是不行的:
#include <iostream>
using namespace std;
int main()
{
enum class Color{red, green, blue};
cout<<Color::red<<endl;
return 0;
}
编译会报错,因为该枚举类没有重载
C++(11):枚举类_风静如云的博客-CSDN博客_c++11 枚举类
介绍了枚举类使用的好处。
不过如果直接输出枚举类的值是不行的:
#include <iostream>
using namespace std;
int main()
{
enum class Color{red, green, blue};
cout<<Color::red<<endl;
return 0;
}
编译会报错,因为该枚举类没有重载