-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinher2.cpp
More file actions
121 lines (121 loc) · 1.8 KB
/
inher2.cpp
File metadata and controls
121 lines (121 loc) · 1.8 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "iostream"
using namespace std;
class employee
{
char name[25];
int eno;
public:
employee()
{
strcpy(name,"none");
eno=0;
}
void getdata()
{
cout<<"Enter name: ";
cin>>name;
cout<<"Enter Employee number: ";
cin>>eno;
}
void putdata()
{
cout<<"Name:"<<name<<"\tEmployee number:"<<eno;
}
~employee();
};
class manager: public employee
{
char title[15];
float dues;
public:
manager()
{
strcpy(title,"employee");
dues=0.0;
}
void getdata()
{
employee::getdata();
cout<<"Enter title: ";
cin>>title;
cout<<"Enyer dues: ";
cin>>dues;
}
void putdata()
{
employee::putdata();
cout<<"\tTitle:"<<title<<"\tDues:"<<dues;
}
~manager();
};
class scientist: public employee
{
int noop;
public:
scientist()
{
noop=0;
}
void getdata()
{
employee::getdata();
cout<<"Enter no of publications: ";
cin>>noop;
}
void putdata()
{
employee::putdata();
cout<<"\tPublications:"<<noop;
}
~scientist();
};
class labourer: public employee
{
public:
labourer();
void getdata()
{
employee::getdata();
}
void putdata()
{
employee::putdata();
cout<<"\n";
}
~labourer();
};
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;
}