-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathPokemon.cpp
75 lines (66 loc) · 1.09 KB
/
Pokemon.cpp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* =====================================================================================
*
* Filename: Pokemon.cpp
*
* Description: virtual example
*
* Version: 1.0
* Created: 05/28/2012 04:37:18 PM
* Revision: none
* Compiler: gcc
*
* Author: FamiHug (), [email protected]
* Company: FAMILUG
*
* =====================================================================================
*/
#include<iostream>
using namespace std;
class Pokemon
{
//bool sex; // 0 is female, 1 is male
public:
virtual void sayMyName()
{
cout<<"I'm a pokemon\n";
}
};//Pokemon
class Pichu : public Pokemon
{
public:
void sayMyName()
{
cout<<"Pichu pichu\n";
}
};
class Pikachu :public Pichu
{
public:
void sayMyName()
{
cout<<"Pikachu pikachu\n";
}
};
class Bulbasaur :public Pokemon
{
public:
void sayMyName()
{
cout<<"Bulbasaur bulbasaur\n";
}
};
void say(Pokemon& p)
{
p.sayMyName();
}
int main()
{
Pichu aPichu;
Pikachu aPikachu;
Bulbasaur aBulbasaur;
say(aPichu);
say(aPikachu);
say(aBulbasaur);
return 0;
}