-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab6d.cpp
91 lines (91 loc) · 1.6 KB
/
lab6d.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include<iostream>
#include<iomanip>
using namespace std;
class base
{
protected:
int data;
public:
base()
{
cout<<"base class constructor"<<endl;
}
void read()
{
cout<<"enter base class data value - ";
cin>>data;
}
void display()
{
cout<<"base class data value = "<<data<<endl;
}
};
class derived1:virtual public base
{
protected:
int derv1;
public:
derived1()
{
cout<<"derived1 class constructor"<<endl;
}
void readderv1()
{
cout<<"enter derived1 class data - ";
cin>>derv1;
}
void displayderv1()
{
cout<<"derived1 class data value = "<<derv1<<endl;
}
};
class derived2:virtual public base
{
protected:
int derv2;
public:
derived2()
{
cout<<"derived2 class constructor"<<endl;
}
void readderv2()
{
cout<<"enter derived2 class data - ";
cin>>derv2;
}
void displayderv2()
{
cout<<"derived2 class data value = "<<derv2<<endl;
}
};
class derived3:public derived1,public derived2
{
protected:
int derv3;
public:
derived3()
{
cout<<"derived3 class constructor"<<endl;
}
void readderv3()
{
cout<<"enter derived3 class data - ";
cin>>derv3;
}
void displayderv3()
{
cout<<"derived3 class data value = "<<derv3<<endl;
}
};
int main()
{
derived3 obj;
obj.read();
obj.readderv1();
obj.readderv2();
obj.readderv3();
obj.display();
obj.displayderv1();
obj.displayderv2();
obj.displayderv3();
}