-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path41_Multiple_Inheritance.cpp
More file actions
83 lines (57 loc) · 1.42 KB
/
41_Multiple_Inheritance.cpp
File metadata and controls
83 lines (57 loc) · 1.42 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
80
81
82
83
// Multiple Inheritance...!!
#include<iostream>
using namespace std;
class Base1{
protected:
int base1int;
public:
void set_base1_int(int a){
base1int = a;
}
};
class Base2{
protected:
int base2int;
public:
void set_base2_int(int b){
base2int = b;
}
};
class Base3{
protected:
int base3int;
public:
void set_base3_int(int c){
base3int = c;
}
};
// *********************************************************
// (Multiple) Derived Class Syntax
class Derived : public Base1, public Base2, public Base3{
public:
void show(){
cout << "The value of the Base 1 int is: " << base1int <<endl;
cout << "The value of the Base 2 int is: " << base2int <<endl;
cout << "The value of the Base 3 int is: " << base3int <<endl;
cout << "The sum of Base 1 and Base 2 int is : " << base1int + base2int +base3int <<endl;
}
};
/*
The inherited derived class will look something like this:
Data Members:
base1int --> protected
base2int --> protected
Member Functions :
set_base1int() --> public
set_base2int() --> public
set_show() --> public
*/
int main()
{
Derived objd1;
objd1.set_base1_int(5);
objd1.set_base2_int(7);
objd1.set_base3_int(8);
objd1.show();
return 0;
}