-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path06_employee.cpp
More file actions
executable file
·62 lines (51 loc) · 897 Bytes
/
Copy path06_employee.cpp
File metadata and controls
executable file
·62 lines (51 loc) · 897 Bytes
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
#include <iostream>
#include <cstdlib>
using namespace std;
class Employee{
int age, salary;
char name[20], des[40];
public:
Employee *ptr;
void read();
void display();
};
int main(){
Employee *e = new Employee();
Employee *p1;
int n = 0, c;
p1 = e;
do{
if(n != 0){
p1->ptr = new Employee();
p1 = p1->ptr;
}
cout<<"Employee "<<++n<<" :\n";
p1->read();
p1->ptr = NULL;
cout<<"\nEnter more (1/0) ? ";
cin>>c;
}while(c != 0);
p1 = e;
for(int i = 0; i < n; ++i){
cout<<"\nEmployee "<<i+1<<"\n";
p1->display();
p1 = p1->ptr;
}
return 0;
}
void Employee::read(){
cout<<"Enter name : ";
cin>>name;
cout<<"Designation : ";
cin>>des;
cout<<"Age : ";
cin>>age;
cout<<"Salary : ";
cin>>salary;
}
void Employee::display(){
cout<<"Name : "<<name;
cout<<"\nAge : "<<age;
cout<<"\nDesignation : "<<des;
cout<<"\nSalary : "<<salary<<"\n";
}