int main(){

	Dog dg;
	//dg.setName("Mark"); // this will give error coz setName is protected in dog class, and is unaccessable
	dg.setDogName("Mark");
	dg.show();

	return 0;
}
Beispiel #2
0
int main(int argc, const char * argv[])
{
    //Animal a;//抽象类不能实例化
    
    Dog d;
    d.show();
    
    //抽象类虽然不能实例化,但可以用指针指向子类的对象
    Animal* a = new Dog();
    a->show();
}