-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprog10.cpp
More file actions
78 lines (63 loc) · 1.62 KB
/
prog10.cpp
File metadata and controls
78 lines (63 loc) · 1.62 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
/*
Create a C++ program with classes basicInfo and deptInfo to store employee and
department details, then use a derived class employee with methods to input and
display complete employee information using multiple inheritance.
*/
#include <iostream>
#include <string>
using namespace std;
class BasicInfo {
protected:
string name;
int empId;
char gender;
public:
void getBasicInfo() {
cout << "Enter name: ";
cin >> name;
cout << "Employee ID: ";
cin >> empId;
cout << "Enter Gender: ";
cin >> gender;
}
};
class DeptInfo {
protected:
string deptName, assignedWork;
int timeToComplete;
public:
void getDeptInfo() {
cout << "Enter Dept Name: ";
cin >> deptName;
cout << "Enter Assigned Word: ";
cin >> assignedWork;
cout << "Enter Time to Complete: ";
cin >> timeToComplete;
}
};
class Employee : public BasicInfo, public DeptInfo {
public:
void getEmployeeInfo() {
cout << "Enter employee's basic info" << endl;
getBasicInfo();
cout << "Enter employee's dept info" << endl;
getDeptInfo();
}
void printEmployeeInfo() {
cout << "Enployee's Information: " << endl;
cout << "Basic Information: " << endl;
cout << "\tName: " << name << endl;
cout << "\tEmployee ID: " << empId << endl;
cout << "\tGender: " << gender << endl;
cout << "Department Information: " << endl;
cout << "\tName: " << deptName << endl;
cout << "\tAssigned Work: " << assignedWork << endl;
cout << "\tTime to Complete: " << timeToComplete << endl;
}
};
int main() {
Employee e1;
e1.getEmployeeInfo();
e1.printEmployeeInfo();
return 0;
}