Repository navigation
Expand file tree
/
Copy pathclass_Employee.cpp
More file actions
91 lines (75 loc) · 1.72 KB
/
Copy pathclass_Employee.cpp
File metadata and controls
91 lines (75 loc) · 1.72 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
//bsdsf25m050
#include<iostream>
#include<string>
using namespace std;
const int NAME_SIZE = 50;
const int DEPT_SIZE = 50;
class Employee{
private:
int ID;
char name[NAME_SIZE];
char Dept_name[DEPT_SIZE];
public:
Employee(){
ID=0;
name[0]='\0';
Dept_name[0]='\0';
}
Employee(int id, char empname[], char empdept[]){
ID =id;
strcpy(name,empname);
strcpy(Dept_name,empdept);
}
Employee(int empid, char emppname[]){
ID =empid;
strcpy(name,emppname);
Dept_name[0]='\0';
}
void setid(int i){
ID=i;
}
void setname(char naame[]){
strcpy(name,naame);
}
void setdept(char dept[]){
strcpy(Dept_name,dept);
}
int getid()const{
return ID;
}
const char* getname()const{
return name;
}
const char* getdept()const{
return Dept_name;
}
void Display(){
cout<<"employee details: "<<endl;
cout<<"employee id: "<<ID<<endl;
cout<<"employee name: "<<name<<endl;
cout<<"employee dept name: "<<Dept_name<<endl;
}
};
int main(){
int size;
cout<<" size of array: "<<endl;
cin>>size;
Employee *arr=new Employee[size];
for(int i=0;i<size; i++){
cout<<"enter details for employee (id, name, deptname)"<<i+1<<" : "<<endl;
int id;
char name[NAME_SIZE];
char deptname[DEPT_SIZE];
cin>>id>>name>>deptname;
arr[i].setid(id);
arr[i].setname(name);
arr[i].setdept(deptname);
}
cout<<"INFORMATION: "<<endl;
for(int i=0;i<size; i++){
arr[i].Display();
cout<<endl;
}
delete [] arr;
return 0;
}