新的enum的作用域不在是全局的,不用担心命名冲突问题不能隐式转换成其他类型可以指定用特定的类型来存储enum enum class Color2 { RED = 2, YELLOW, BLUE }; Color2 c2 = Color2::RED; cout << static_cast<int>(c2) << endl; //必须转!