-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23_oops.cpp
More file actions
49 lines (49 loc) · 999 Bytes
/
23_oops.cpp
File metadata and controls
49 lines (49 loc) · 999 Bytes
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
#include<iostream>
using namespace std;
/*syntax for inheriting in multiple inheritance
class DerivedC: visibility-mode base1 , visibility-mode base2
{
class body of class "derivedC"
}
*/
class Base1{
protected:
int base1int;
public:
void set_base1int(int a){
base1int = a;
}
};
class Base2{
protected:
int base2int;
public:
void set_base2int(int a){
base2int = a;
}
};
class Base3{
protected:
int base3int;
public:
void set_base3int(int a){
base3int = a;
}
};
class Derived: public Base1 , public Base2, public Base3{
public:
void show(){
cout<<"The value of Base1 is"<<" " << base1int<<endl;
cout<<"The value of Base2 is" <<" "<< base2int<<endl;
cout<<"The value of Base3 is" <<" "<< base3int<<endl;
cout<<"The sum of these is"<<" " << base1int + base2int + base3int<<endl;
}
};
int main(){
Derived khushi;
khushi.set_base1int(23);
khushi.set_base2int(7);
khushi.set_base3int(20);
khushi.show();
return 0;
}