C++错误集锦之:error C2243: 'type cast' : conversion exists, but is inaccessible

看看你的父类是否是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;}
};

这样就会报错。

你可能感兴趣的:(C++,c,Class)