Scope resolution operator on enums a compiler-specific extension?

前端 未结 5 1693
你的背包
你的背包 2020-12-19 05:33

On this question, there\'s an answer that states:

You can use typedef to make Colour enumeration type accessible without specifying it\'s \"full name\

5条回答
  •  一整个雨季
    2020-12-19 06:02

    What you can do to get around it is to create a namespace that's the same name as the enumeration. That will effectively add the enumeration values into their own scope and you can use the name of the enumeration/namespace to refer to them. Of course it only works for enumerations that would otherwise exist in the global (or another namespace) scope.

    There's also an article on this issue somewhere.

提交回复
热议问题