【发布时间】:2013-03-05 06:01:05
【问题描述】:
我使用 VS2010,它没有 C++11 的强类型枚举。我可以没有强类型,但无论如何,我希望将枚举排除在我的类的命名空间之外。
class Example{
enum Color{
red,
green,
blue
};
int Rainbows{
Color x = red; // this should be impossible
Color y = Color::green; // this is the only way at the enumerations
}
};
我的问题是,在 C++11 之前,最好的方法是什么?
【问题讨论】:
标签: c++ visual-studio-2010 enums namespaces