-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathproblem.cpp
96 lines (89 loc) · 1.96 KB
/
problem.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
HARSHIT SRIVASTAVA 211200 <[email protected]>
Wed, 14 Sept, 12:07
to me
#include <iostream>
using namespace std;
class Employee2;
class Manager;
class Employee1{
private:
string name;
int salary;
public:
Employee1(){
name = '\0';
salary = 0;
}
void setdata(){
cout<<"Enter the name of Employee1: ";
cin>>name;
cout<<"Enter the salary of "<<name<<": ";
cin>>salary;
}
void putdata(){
cout<<"Name: "<<name<<endl;
cout<<"Salary: "<<salary<<endl;
}
friend void increase_salary(Employee1 a, Employee2 b, Manager m);
};
class Employee2{
private:
string name;
int salary;
public:
Employee2(){
name = '\0';
salary = 0;
}
void setdata(){
cout<<"Enter the name of Employee2: ";
cin>>name;
cout<<"Enter the salary of "<<name<<": ";
cin>>salary;
}
void putdata(){
cout<<"Name: "<<name<<endl;
cout<<"Salary: "<<salary<<endl;
}
friend void increase_salary(Employee1 a, Employee2 b, Manager m);
};
class Manager{
private:
int increment;
public:
Manager(){
increment = 0;
}
void setdata(){
cout<<"Ënter the increment value: ";
cin>>increment;
}
friend void increase_salary(Employee1 a, Employee2 b, Manager m);
};
void increase_salary(Employee1 a, Employee2 b, Manager m){
cout<< "Increase salary of "<<a.name<<" or "<<b.name<<"?"<<endl;
int input;
cin>>input;
if(input == 0){
a.salary+=m.increment;
cout<<"Name: "<<a.name<<endl;
cout<<"New Salary: "<<a.salary<<endl;
}
else if(input == 1){
b.salary+=m.increment;
cout<<"Name: "<<b.name<<endl;
cout<<"New Salary: "<<b.salary<<endl;
}
}
int main() {
Employee1 x;
Employee2 y;
x.setdata();
x.putdata();
y.setdata();
y.putdata();
Manager m;
m.setdata();
increase_salary(x, y, m);
return 0;
}