-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek_9b.cpp
More file actions
47 lines (44 loc) · 941 Bytes
/
week_9b.cpp
File metadata and controls
47 lines (44 loc) · 941 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
//week_9b.cpp
#include<iostream>
using namespace std;
class Base1{
private:
int data1=5000;
public:
int data2=100000;
void fun1(){
cout<<"Base class Function is called\n";
}
int getter(){
return data1;
}
};
class Base2{
public:
int data4;
void base2Fun(){
cout<<"Enter the data\n";
cin>>data4;
}
void fun1(){
cout<<"Base2 class function is called\n";
}
void fun2(){
cout<<"fun2 is called\n";
}
};
class Derived1: public Base2, public virtual Base1{
public:
int data3=30000;
void total(){
cout<<"Sum of data2 and data3 and data4 is "<<data2+data3+data4<<endl;
}
};
int main(){
Base1 b1;
cout<<"The value of data1 is "<<b1.getter()<<endl;
b1.fun1();
Derived1 d1;
d1.base2Fun();
d1.total();
}