#include <iostream>
using namespace std;
class Animal
{
private:
string name;
public:
Animal(){}
Animal(string name):name(name)
{
}
virtual void perform()
{
cout << "我是" << name <<endl;
}
};
class Lion:public Animal
{
private:
string Lion_name;
public:
Lion(){}
Lion(string Lion_name):Lion_name(Lion_name)
{
}
void perform()
{
cout << "我是" << Lion_name << endl;
}
};
class Monkey:public Animal
{
private:
string Monkey_name;
public:
Monkey(){}
Monkey(string Monkey_name):Monkey_name(Monkey_name){}
void perform()
{
cout << "我是" << Monkey_name << endl;
}
};
int main()
{
Animal a("讲解员");
Animal *p = &a;
p->perform();
Lion l("辛巴");
p = &l;
p->perform();
Monkey m("悟空");
p = &m;
p->perform();
return 0;
}