-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut41.cpp
executable file
·82 lines (78 loc) · 1.66 KB
/
tut41.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
#include <iostream>
// multiple inheritance
class BaseClass1 {
private:
int base1a;
protected:
int base1b;
public:
int base1c;
int setBase1(int a, int b, int c) {
base1a = a;
base1b = b;
base1c = c;
return 0;
}
int getBase1a() {
return base1a;
}
int getBase1b() {
return base1b;
}
int getBase1c() {
return base1c;
}
};
class BaseClass2 {
private:
int base2a;
protected:
int base2b;
public:
int base2c;
int setBase2(int a, int b, int c) {
base2a = a;
base2b = b;
base2c = c;
return 0;
}
int getBase2a() {
return base2a;
}
int getBase2b() {
return base2b;
}
int getBase2c() {
return base2c;
}
};
class DerivedClass : public BaseClass1, public BaseClass2 {
private:
int deriveda;
protected:
int derivedb;
public:
int derivedc;
int setDerived(int a, int b, int c) {
deriveda = a;
derivedb = b;
derivedc = c;
return 0;
}
int getderiveda() {
return deriveda;
}
int getderivedb() {
return derivedb;
}
int getderivedc() {
return derivedc;
}
};
int main() {
DerivedClass d;
d.setBase1(1, 2, 3);
d.setBase2(4, 5, 6);
d.setDerived(7, 8, 9);
return 0;
}