看看你的父类是否是public的,如下是正确的范例:
class Dog:public Animal { public: Dog(){cout<<"dog constructor"<<endl;} virtual ~Dog(){cout<<"dog destructor"<<endl;} void cry() const{cout<<"dog cry..."<<endl;} };
class Dog:Animal { public: Dog(){cout<<"dog constructor"<<endl;} virtual ~Dog(){cout<<"dog destructor"<<endl;} void cry() const{cout<<"dog cry..."<<endl;} };