我有一个包含枚举
的类:
class appearance{
// ... stuff ...
enum color {BLUE, RED, GREEN};
};
我想附加命名空间的一部分(使用 using
),这样我就可以将 BLUE
的值简单地称为 BLUE
,而不是 appearance::BLUE
。同时,我想将 enum
保留在 class{}
中,因为我认为这是最自然的做法。我尝试了 namespace
和 using
的各种组合,但都无济于事。
有什么建议吗???
最佳答案
我认为这是不可能的。 AFAIK,您可以按照规定在另一个类或结构中使用 using appearance::color
here .
A using declaration in a class A may name one of the following:
A member of a base class of A
A member of an anonymous union that is a member of a base class of A
An enumerator for an enumeration type that is a member of a base class of A
关于c++ - 导出类的部分命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3925244/