-
Notifications
You must be signed in to change notification settings - Fork 0
/
poly3.cpp
53 lines (53 loc) · 1.06 KB
/
poly3.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
#include<iostream>
using namespace std;
class Teacher{
int salary;string name;
public:
Teacher(string n, int sal):name(n), salary(sal){
}
int getMonthlySalary(){
return salary+salary*0.1;
}
string getName(){ return name;
}
};
class Driver{
string name; int daily;
public:
Driver(string n, int da):name(n), daily(da){
}
string getName(){ return name;
}
int getMonthlyWages(){
return daily*30;
}
};
class Banker{
string name; int salary;
public:
Banker(string n, int sa):name(n), salary(sa){
}
string getName(){ return name;
}
int getMonthlyRemuneration(){
return salary+salary*0.2;
}
};
void display(Teacher t){
cout<<t.getName()<<" ***** "<<t.getMonthlySalary()<<endl;
}
void display(Banker b){
cout<<b.getName()<<" ***** "<<b.getMonthlyRemuneration()<<endl;
}
void display(Driver d){
cout<<d.getName()<<" ***** "<<d.getMonthlyWages()<<endl;
}
int main (){
Teacher tchr("Mujahid", 100000);
Driver dr("Ali", 2500);
Banker bnkr("Ahmad", 90000);
display(tchr);
display(bnkr);
display(dr);
return 0;
}