这是我的代码/命名空间:
namespace myNamespace {
enum MyType {
ASD1,
ASD2,
ASD3
};
struct MyClass {
MyType mMyType;
MyClass(MyType myType = MyType::ASD1) : mMyType(myType) {
}
};
}
现在,如果我在另一个结构中尝试此代码:
struct X
{
myNamespace::MyClass *pMyClass1 = new myNamespace::MyClass(myNamespace::MyType::ASD2);
};
它工作得很好,但如果我试试这个:
struct X
{
myNamespace::MyClass mMyClass1(myNamespace::MyType::ASD2);
};
它说'myNamespace::MyType::ASD2' is not a type
。
既然都已经声明过了,为什么会这样呢?