我有以下问题:
class Bar
{
std::array<int, Foo::Baz::LEN> array;
};
class Foo
{
Bar bar;
public:
enum class Baz
{
VAL_1 = 0, VAL_2, LEN
};
}
有没有办法将枚举类的声明与 Foo
分开,同时将其保留在 class Foo
的命名空间中?
最佳答案
你不能那样做。
您需要将 enum
的定义移到 Bar
的定义之前,或者将其定义在 Bar
中。
关于C++如何使用其中也包含此类的类中的枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37893254/