-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritance_PartTimeEmployeeDisplay.cpp
More file actions
58 lines (46 loc) · 1.18 KB
/
Inheritance_PartTimeEmployeeDisplay.cpp
File metadata and controls
58 lines (46 loc) · 1.18 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
#include <iostream>
using namespace std;
const int MAX_LENGTH = 50;
class Employee {
protected:
char name[MAX_LENGTH];
char address[MAX_LENGTH];
int age;
public:
void getData() {
cout << "Enter name: ";
cin.getline(name, MAX_LENGTH);
cout << "Enter address: ";
cin.getline(address, MAX_LENGTH);
cout << "Enter age: ";
cin >> age;
cin.ignore(); // Ignore the remaining newline character
}
void displayData() {
cout << "Name: " << name << endl;
cout << "Address: " << address << endl;
cout << "Age: " << age << endl;
}
};
class Part_time : public Employee {
private:
float payment;
public:
void getPayment() {
cout << "Enter payment: Rs.";
cin >> payment;
cin.ignore(); // Ignore the remaining newline character
}
void displayData() {
Employee::displayData();
cout << "Payment: Rs." << payment << endl;
}
};
int main() {
Part_time pt;
pt.getData();
pt.getPayment();
cout << "\nPart-Time Employee Details:\n";
pt.displayData();
return 0;
}