且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将枚举导入 C++ 中的不同命名空间?

更新时间:2022-06-25 00:47:39

将现有命名空间包装在嵌套命名空间中,然后在原始命名空间中使用"该命名空间.

Wrap the existing namespace in a nested namespace which you then "use" in the original namespace.

namespace foo
{
    namespace bar_wrapper {
        enum bar {
            A
        };
    }
    using namespace bar_wrapper;
}

namespace buzz
{
    using namespace foo::bar_wrapper;
}