-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab6b.cpp
71 lines (70 loc) · 1.16 KB
/
lab6b.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
64
65
66
67
68
69
70
71
#include<iostream>
#include<iomanip>
using namespace std;
class base1
{
protected:
int base;
public:
base1()
{
cout<<"base1 class constructor"<<endl;
}
void readbase1()
{
cout<<"enter base1 class data - ";
cin>>base;
}
void displaybase1()
{
cout<<"base1 data value = "<<base<<endl;
}
};
class base2
{
protected:
int base1;
public:
base2()
{
cout<<"base2 class constructor"<<endl;
}
void readbase2()
{
cout<<"enter base2 class data - ";
cin>>base1;
}
void displaybase2()
{
cout<<"base2 data value = "<<base1<<endl;
}
};
class derived:public base2,public base1
{
protected:
int derv;
public:
derived()
{
cout<<"derived class constructor"<<endl;
}
void readderv()
{
cout<<"enter derived class data - ";
cin>>derv;
}
void displayderv()
{
cout<<"derived data value = "<<derv<<endl;
}
};
int main()
{
derived obj;
obj.readbase1();
obj.readbase2();
obj.readderv();
obj.displaybase1();
obj.displaybase2();
obj.displayderv();
}