-
Notifications
You must be signed in to change notification settings - Fork 0
/
7_INHERITANCE.cpp
100 lines (91 loc) · 1.91 KB
/
7_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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//OOP PROGRAM NO. 6 MULTIPLE INHERITANCE
#include<iostream>
using namespace std;
class prof //parent class
{
protected:
char exp[20];
char field[20];
public:
void getdata()
{
cout<<"\t\tPROFESSIONAL FIELD INFO";
cout<<"\nenter the field of study : ";
cin>>field;
cout<<"enter year of exp : ";
cin>>exp;
}
};
class acad //parent class
{
protected:
char yop[20];
char marks[20];
public:
void getdata()
{
cout<<"\t\tACADEMIC FIELD INFO";
cout<<"\nenter the year of passing : ";
cin>>yop;
cout<<"enter marks : ";
cin>>marks;
}
};
class pers //parent class
{
protected:
char nm[20];
char bg[20];
char boy[20];
public:
void getdata()
{
cout<<"\t\tPERSONAL FIELD INFO";
cout<<"\nenter the name : ";
cin>>nm;
cout<<"enter blood group : ";
cin>>bg;
cout<<"enter birth date: ";
cin>>boy;
}
};
class biodata : public prof , public acad , public pers //child class
{
public:
void display()
{
cout<<"\n\t\tBIODATA";
cout<<"\nPERSONAL";
cout<<"\n\tname: "<<nm;
cout<<"\n\tblood group: "<<bg;
cout<<"\n\tbirth date: "<<boy;
cout<<"\nPROFESSIONAL";
cout<<"\n\tfield of study: "<<field;
cout<<"\n\texperience: "<<exp;
cout<<"\nACADEMIC";
cout<<"\n\tyear of passing: "<<yop;
cout<<"\n\tmarks: "<<marks;
cout<<"\n********************************************"<<endl;
}
};
main()
{
int n,i;
biodata b[10];
cout<<"\nenter the number of employee - ";
cin>>n;
for(i=1;i<=n;i++)
{
cout<<"\t\tEMPLOYEE "<<i<<"\n";
b[i].prof::getdata(); //IMP :: to call parent class function
b[i].acad::getdata();
b[i].pers::getdata();
cout<<"\n********************************************"<<endl;
}
cout<<"******************************************"<<endl;
for(i=1;i<=n;i++)
{
cout<<"\t\tEMPLOYEE "<<i;
b[i].display();
}
}