How do you import an enum into a different namespace in C++?

前端 未结 5 1752
心在旅途
心在旅途 2020-12-11 14:20

I have an enum in a namespace and I\'d like to use it as if it were in a different namespace. Intuitively, I figured I could use \'using\' or \'typedef\' to accomplish this,

5条回答
  •  一向
    一向 (楼主)
    2020-12-11 15:00

    If you really need to do this, try using namespace foo; instead of using foo::bar;. However, it's a much better idea to encapsulate the enum in a class or in another namespace.

提交回复
热议问题