-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathg.cpp
100 lines (88 loc) · 1.11 KB
/
g.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
/*
topic:- accessiblity(advanced)
*/
#include <iostream>
using namespace std;
class Base
{
int x;
protected:
int y;
public:
Base(int x = 0, int y = 0)
{
this->x = x;
this->y = y;
cout << "Base cons\n";
}
~Base()
{
cout << "Base des\n";
}
void setx(int x)
{
this->x = x;
}
void sety(int y)
{
this->y = y;
}
void show()
{
cout << "x: " << x << " y: " << y << "\n";
}
};
class D1 : virtual public Base
{
};
class D2 : virtual public Base
{
};
class DD1 : public D1
{
public:
int on;
DD1()
{
cout << "DD1 cons\n";
}
~DD1()
{
cout << "DD1 des\n";
}
};
class DD2 : public D2
{
public:
int to;
DD2()
{
cout << "DD2 cons\n";
}
~DD2()
{
cout << "DD2 des\n";
}
};
class DDD1 : private DD1, protected DD2
{
};
class QD1 : public DDD1
{
public:
void ck()
{
show();
}
};
int main()
{
//run the program
DDD1 a;
QD1 b;
b.ck();
//a.on = 1;
//a.to = 2;
//a.show();
return 0;
}