X-mind
#include
using namespace std;
class Animal
{
private:
string name;
public:
Animal() {}
Animal(string name):name(name)
{}
virtual void prefrom() = 0;
void show()
{
cout << name << ":";
}
};
template <class T>
class Anmimal_action:Animal
{
private:
T action;
public:
Anmimal_action() {}
Anmimal_action(T n,T a):Animal(n),action(a)
{}
void prefrom()
{
Animal::show();
cout << action << endl;
}
};
int main()
{
Anmimal_action<string> a1("狮子","狗叫");
Anmimal_action<string> a2("大象","摇耳朵");
Anmimal_action<string> a3("猴子","挠头");
a1.prefrom();
a2.prefrom();
a3.prefrom();
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43