-
Notifications
You must be signed in to change notification settings - Fork 0
/
hybrid_inheritance.cpp
78 lines (78 loc) · 1.02 KB
/
hybrid_inheritance.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
#include<iostream>
using namespace std;
class person{
protected:
char name[20];
int code;
public:
void getdata()
{
cout<<"enter name";
cin>>name;
cout<<"enter code";
cin>>code;
}
void putdata()
{
cout<<"name is"<<name<<endl;
cout<<"code is"<<code<<endl;
}
};
class account:public person
{
protected:
int pay;
public:
void getd()
{
cout<<"enter pay";
cin>>pay;
}
void putd()
{
cout<<"pay is"<<pay<<endl;
}
};
class admin:public person{
protected:
int exp;
public:
void getinfo()
{
cout<<"enter years of experience";
cin>>exp;
}
void putinfo()
{
cout<<"experience is"<<exp<<endl;
}
};
class master:public account,public admin
{
private:
char dep[20];
public:
void get()
{
cout<<"enter dept";
cin>>dep;
}
void put()
{
cout<<"department is"<<dep<<endl;
}
};
int main()
{
account acc;
master obj;
acc.getdata();
acc.getd();
obj.getinfo();
obj.get();
cout<<"employee details";
acc.putdata();
acc.putd();
obj.putinfo();
obj.put();
}