我正在开发一个派生自另一个类的类,但我被卡住了,使用以下代码:
template <class A, class B, class C>
class BaseClass
{
public:
BaseClass(){}
virtual void amethod( A* aPtr=0)
{
mAPtr=aPtr;
}
virtual void init()=0;
protected:
A * mAPtr;
B* mBPtr;
C * mCPtr;
};
template <class A,class B,class C>
class ChildClass: public BaseClass<A,B,C>
{
public:
ChildClass( A* aAptr =0, B * aBPtr= 0, C* aCPtr= 0):mAPtr(aAptr)
,mBPtr(aBPtr)
,mCPtr(aCPtr)
{}
};
int main()
{
return 0;
}
编译器说子类没有任何父字段。
编译器输出:
In constructor 'ChildClass<A, B, C>::ChildClass(A*, B*, C*)'
In constructor 'ChildClass<A, B, C>::ChildClass(A*, B*, C*)'
error: class 'ChildClass<A, B, C>' does not have any field named 'mAPtr'
error: class 'ChildClass<A, B, C>' does not have any field named 'mBPtr'
error: class 'ChildClass<A, B, C>' does not have any field named 'mCPtr'
我在谷歌搜索,但我找不到答案:提前谢谢