-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultipleInheritance.cpp
63 lines (51 loc) · 1.06 KB
/
MultipleInheritance.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
#include<iostream>
using namespace std;
//The syntax of inheriting multiple inheritances
// class Derived: visibility-mode base1, visibility-mode base2
// {
// Class body of class "DerivedC"
// };
class Base1{
protected:
int data1;
public:
void set_data1(int a){
data1 = a;
}
void get_data1(void){
cout<<"The Value of Data 1 is "<<data1<<endl;
}
};
class Base2{
protected:
int data2;
public:
void set_data2(int a){
data2 = a;
}
void get_data2(void){
cout<<"The Value of Data 1 is "<<data2<<endl;
}
};
class Derived : public Base1 , public Base2{
int data3;
public:
void Display(void){
get_data1();
get_data2();
cout<<"The Value of Data 3 is "<<(data1+data2)<<endl;
}
};
int main(){
Derived Del;
Del.set_data1(23);
Del.set_data2(34);
Del.Display();
return 0;
}
/*
OutPut :
The Value of Data 1 is 23
The Value of Data 1 is 34
The Value of Data 3 is 57
*/