-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram to Maintain Employee Database using Virtual class .cpp
136 lines (127 loc) · 2.72 KB
/
Program to Maintain Employee Database using Virtual class .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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* C++ Program to Maintain Employee Database using Virtual class */
#include <iostream>
#include <stdlib.h>
using namespace std;
class person
{
protected:
char name[20];
int code;
public:
void getdetail(void)
{
cout<<"\n\nEnter name :- ";
cin>>name;
cout<<"\nEnter code :- ";
cin>>code;
}
void dispdetail(void)
{
cout<<"\n\nNAME :- "<<name;
cout<<"\nCODE :- "<<code;
}
};
class account : virtual public person
{
protected:
float pay;
public:
void getpay(void)
{
cout<<"\nEnter Pay amount :- ";
cin>>pay;
}
void dispay(void)
{
cout<<"\nPAY :- "<<pay;
}
};
class admin : virtual public person
{
protected:
int experience;
public:
void getexpr(void)
{
cout<<"\nEnter Experience in yrs :- ";
cin>>experience;
}
void dispexpr(void)
{
cout<<"\nEXPERIENCE:- "<<experience;
}
};
class master : public account, public admin
{
public:
void create(void)
{
cout<<"\n\n=====GETDATA IN=====\n";
getdetail();
getpay();
getexpr();
}
void display(void)
{
cout<<"\n\n=====DISPLAY DETAILS=====\n";
dispdetail();
dispay();
dispexpr();
}
void update(void)
{
cout<<"\n\n=====UPDATE DETAILS=====\n";
cout<<"\nChoose detail you want to update\n";
cout<<"1) NAME\n";
cout<<"2) CODE\n";
cout<<"3) EXPERIENCE\n";
cout<<"4) PAY\n";
cout<<"Enter your choice:- ";
int choice;
cin>>choice;
switch(choice)
{
case 1 : cout<<"\n\nEnter name : - ";
cin>>name;
break;
case 2 : cout<<"\n\nEnter code :- ";
cin>>code;
break;
case 3 : cout<<"\n\nEnter pay :- ";
cin>>pay;
break;
case 4 : cout<<"\n\nEnter Expereince :- ";
cin>>experience;
break;
default: cout<<"\n\nInvalid choice\n\n";
}
}
};
int main()
{
master ob1;
int choice;
while(1)
{
cout<<"\n\n=====EMPLOYE DATABASE=====\n\n";
cout<<"\nChoose Operation you want to perform\n";
cout<<"1) Create Record\n";
cout<<"2) Display Record\n";
cout<<"3) Update Record\n";
cout<<"4) Exit\n";
cout<<"\nEnter your choice:- ";
cin>>choice;
switch(choice)
{
case 1 : ob1.create();
break;
case 2 : ob1.display();
break;
case 3 : ob1.update();
break;
case 4 : exit(1);
default : cout<<"\n\nInvalid Choice\nTry Again\n\n";
}
}
return 0;
}