我们正试图将一个类隐藏在一个新的命名空间后面,但我们希望保留原来的名称。
namespace first {
class Logger { ... };
}
namespace second {
using Logger = first::Logger;
}
error: definition of type 'Logger' conflicts with type alias of the same name class Logger;
最佳答案
是的,我们可以:
namespace first {
class Logger { };
}
namespace second {
typedef first::Logger Logger;
}
typedef is apparently equivalent to using (在 C++11 中),更加实用。
关于c++ - 有没有办法将类嵌入到同名的新命名空间中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35880793/