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
|
#include <iostream>
using namespace std;
class A {
int a;
public :
A(int a) {
this->a = a;
}
void dispA() {
cout << a << endl;
}
};
class B : virtual public A{
int b;
public :
B(int a, int b) : A(a) {
this->b = b;
}
void dispB() {
cout << b << endl;
}
};
class C : virtual public A {
int c;
public :
C(int a, int c) : A(a) {
this->c = c;
}
void dispC() {
cout << c << endl;
}
};
class D : public B, public C {
int d;
public :
D(int a, int b, int c, int d) : B(a, b), C(a, c), A(a) {
this->d = d;
}
void dispD() {
cout << d << endl;
}
};
void main() {
D dd(1, 2, 3, 4);
dd.dispD();
dd.dispC();
dd.dispB();
dd.dispA();
}
|
cs |
'Programming > [C++]' 카테고리의 다른 글
[C++] pointer (포인터) (0) | 2018.03.21 |
---|---|
[C++] 다양한 포인터(pointer) (0) | 2018.03.21 |
[C++] Template(템플릿) (0) | 2018.03.21 |
[C++] Template 함수 (템플릿 함수) (0) | 2018.03.21 |
[C++] Template Class (템플릿 클래스) (0) | 2018.03.21 |