Class A{
public:
MyVec<A> test; //problem error: ‘MyVec’ does not name a type
};
Class B{
public:
template<typename Obj>
Class MyVec{
//some methods...
};
private:
MyVec<A> test1; //ok
};编译器对定义test的代码行进行报错。
发布于 2011-05-08 05:07:47
在定义A之前,您没有定义甚至没有声明MyVec,这使得该类型不可能在A中使用,这是因为声明的顺序。
发布于 2011-05-08 05:03:02
MyVec的全名是B::MyVec。当您在B中时,B::部分是可选的。
https://stackoverflow.com/questions/5923973
复制相似问题