-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiple Inheritance Example.cpp
More file actions
79 lines (68 loc) · 1.81 KB
/
Multiple Inheritance Example.cpp
File metadata and controls
79 lines (68 loc) · 1.81 KB
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
#include <iostream>
using namespace std;
class ABC {
private:
int valueA, valueB, valueC;
public:
void inputValues() {
cout << "Enter the value for A: ";
cin >> valueA;
cout << "\nEnter the value for B: ";
cin >> valueB;
cout << "\nEnter the value for C: ";
cin >> valueC;
}
void outputValues() {
cout << "\nA = " << valueA
<< "\nB = " << valueB
<< "\nC = " << valueC;
}
};
class XYZ {
private:
int valueX, valueY, valueZ;
public:
void inputValues() {
cout << "\nEnter the value for X: ";
cin >> valueX;
cout << "\nEnter the value for Y: ";
cin >> valueY;
cout << "\nEnter the value for Z: ";
cin >> valueZ;
}
void outputValues() {
cout << "\nX = " << valueX
<< "\nY = " << valueY
<< "\nZ = " << valueZ;
}
};
class DEF : public ABC, public XYZ {
private:
int valueD, valueE, valueF;
public:
void inputValues() {
ABC::inputValues(); // Call inputValues() from ABC
XYZ::inputValues(); // Call inputValues() from XYZ
cout << "\nEnter the value for D: ";
cin >> valueD;
cout << "\nEnter the value for E: ";
cin >> valueE;
cout << "\nEnter the value for F: ";
cin >> valueF;
}
void outputValues() {
ABC::outputValues(); // Call outputValues() from ABC
XYZ::outputValues(); // Call outputValues() from XYZ
cout << "\nD = " << valueD
<< "\nE = " << valueE
<< "\nF = " << valueF <<endl <<endl;
}
};
int main() {
DEF obj;
obj.inputValues();
obj.outputValues();
obj.inputValues();
obj.outputValues();
return 0;
}