定义哺乳动物类Mammal,再由此派生出狗类Dog,定义一个Dog类的对象
//你的程序将被嵌在这里
int main()
{
Dog d;
d.setAge(4);
d.setWeight(12);
d.setColor("Black");
cout<<d.getAge()<<endl;
cout<<d.getWeight()<<endl;
cout<<d.getColor()<<endl;
d.speak();
return 0;
}
Sample Output
Constructor in Mammal. Constructor in Dog. 4 12 Black Dog sound wang,wang,wang! Destructor in Dog. Destruc