-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
118 lines (93 loc) · 1.46 KB
/
main.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <stdio.h>
class Base
{
public:
Base();
virtual ~Base();
virtual void Func1();
virtual float Func2(int arg1);
int a;
float b;
};
Base::Base()
{
printf("Base::Construct\n");
a = 0;
b = 0.f;
}
Base::~Base()
{
printf("Base::Destruct\n");
}
void Base::Func1()
{
printf("Base::Func1\n");
}
float Base::Func2(int arg1)
{
printf("Base::Func2 arg1=%d\n", arg1);
return 1.0f;
}
class ChildOne : public Base
{
public:
ChildOne();
virtual ~ChildOne();
virtual void Func1();
char c;
};
ChildOne::ChildOne()
{
printf("ChildOne::Construct\n");
c = 0;
}
ChildOne::~ChildOne()
{
printf("ChildOne::Destruct\n");
}
void ChildOne::Func1()
{
printf("ChildOne::Func1\n");
}
class ChildTwo : public ChildOne
{
public:
ChildTwo();
virtual ~ChildTwo();
virtual float Func2(int arg1);
short c;
short d;
};
ChildTwo::ChildTwo()
{
printf("ChildTwo::Construct\n");
c = 0;
d = 0;
}
ChildTwo::~ChildTwo()
{
printf("ChildTwo::Destruct\n");
}
float ChildTwo::Func2(int arg1)
{
printf("ChildTwo::Func2 arg1=%d\n", arg1);
return 1.0f;
}
int main()
{
Base* pBase;
pBase = new Base();
pBase->Func1();
pBase->Func2(11);
delete pBase;
printf("\n");
pBase = new ChildOne();
pBase->Func1();
pBase->Func2(12);
delete pBase;
printf("\n");
pBase = new ChildTwo();
pBase->Func1();
pBase->Func2(13);
delete pBase;
}