#include <iostream>
using namespace std;
class Animal
{
private:
int quantity;
public:
Animal(){}
Animal(int quantity):quantity(quantity)
{}
virtual void perform() =0 ;
};
class duck:public Animal
{
private:
string name;
public:
duck(){}
duck(int quantity,string name):Animal(quantity),name(name)
{}
void perform()
{
cout << "可达鸭--->哥达鸭" << endl;
}
};
class tiger:public Animal
{
private:
string name;
public:
tiger(){}
tiger(int quantity,string name):Animal(quantity),name(name)
{}
void perform()
{
cout << "宇宙第一咆哮烈焰虎" << endl;
}
};
int main()
{
Animal *p;
duck d1(95,"可达鸭");
p=&d1;
p->perform();
tiger t1(15,"火斑喵");
p=&t1;
p->perform();
return 0;
}
12.5作业
最新推荐文章于 2024-11-06 11:05:01 发布