-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
130 lines (103 loc) · 1.41 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
119
120
121
122
123
124
125
126
127
#include "../../GUI/std_lib.h"
using namespace std;
class B1
{
public:
virtual void vf ()
{
cout << "B1::vf()" << endl;
}
void f ()
{
cout << "B1::f()" << endl;
}
virtual void pvf () = 0;
};
class D1:
public B1
{
public:
void vf ()
{
cout << "D1::vf()" << endl;
}
void f ()
{
cout << "D1::f()" << endl;
}
void pvf ()
{
cout << "D1::pvf()" << endl;
}
};
class D2:
public D1
{
public:
void pvf ()
{
cout << "D2::pvf()" << endl;
}
};
class B2
{
public:
virtual void pvf () = 0;
};
class D21
:
public B2
{
public:
string name {"name"};
void pvf ()
{
cout << "D21::pvf() -> name = " << name << endl;
};
};
class D22:
public B2
{
public:
int integer {1234};
void pvf ()
{
cout << "D22::pvf() -> integer = " << integer << endl;
};
};
void f (B2 &b2)
{
b2.pvf();
}
int main ()
try
{
// B1 b1;
// b1.vf();
// b1.f();
// b1.pvf();
cout << "------------------" << endl;
D1 d1;
d1.vf();
d1.f();
d1.pvf();
cout << "------------------" << endl;
B1 &rd1 = d1;
rd1.vf();
rd1.f();
rd1.pvf();
cout << "------------------" << endl;
D2 d2;
d2.vf();
d2.f();
d2.pvf();
cout << "------------------" << endl;
D21 d21;
D22 d22;
f(d21);
f(d22);
}
catch (exception &e)
{
cerr << "Error: " << e.what() << endl;
}