Enums in C++ have one major problem: You can’t have one name in two different enums like this:
enum Browser
{
None = 0,
Chrome = 1,
Firefox = 2
}
enum OS
{
None = 0,
XP = 1,
Windows7 = 2
}
So what is the best way to handle this issue in this example?
In C++03 you can enclose
enuminside astruct:In C++11 make it an
enum class:In C++03
namespacealso can be wrapped, but personally I find wrappingstruct/classbetter becausenamespaceis more broader. e.g.