-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinher1.cpp
More file actions
102 lines (102 loc) · 1.58 KB
/
inher1.cpp
File metadata and controls
102 lines (102 loc) · 1.58 KB
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
101
102
#include "iostream"
using namespace std;
class employee
{
char name[25];
int eno;
public:
void getdata()
{
cout<<"Enter name: ";
cin>>name;
cout<<"Enter Employee number: ";
cin>>eno;
}
void putdata()
{
cout<<"Name:"<<name<<"\tEmployee number:"<<eno;
}
};
class manager: public employee
{
char title[15];
float dues;
public:
void getdata()
{
employee::getdata();
cout<<"Enter title: ";
cin>>title;
cout<<"Enter dues: ";
cin>>dues;
}
void putdata()
{
employee::putdata();
cout<<"\tTitle:"<<title<<"\tDues:"<<dues;
}
};
class scientist: public employee
{
int noop;
public:
void getdata()
{
employee::getdata();
cout<<"Enter no of publications: ";
cin>>noop;
}
void putdata()
{
employee::putdata();
cout<<"\tPublications:"<<noop;
}
};
class labourer: public employee
{
public:
void getdata()
{
employee::getdata();
}
void putdata()
{
employee::putdata();
cout<<"\n";
}
};
int main()
{
manager m[10];
char ch;
int sn=0,ln=0,mn=0,n,i;
scientist s[10];
labourer l[10];
cout<<"how many records?";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"M for manager, S for scientist, L for labourer:";
cin>>ch;
switch(ch)
{
case 's':
case 'S': s[sn++].getdata();break;
case 'm':
case 'M': m[mn++].getdata();break;
case 'l':
case 'L': l[ln++].getdata();break;
default:cout<<"wrong choice!";
}
}
cout<<"\nMANAGERS\n";
for(i=0;i<mn;i++)
m[i].putdata();
cout<<"\nSCIENTISTS\n";
for(i=0;i<sn;i++)
s[i].putdata();
cout<<"\nLABOURERS\n";
for(i=0;i<ln;i++)
l[i].putdata();
return 0;
}