-
Notifications
You must be signed in to change notification settings - Fork 0
/
poly4.cpp
52 lines (51 loc) · 951 Bytes
/
poly4.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
#include<iostream>
using namespace std;
class Person{
string name;
public:
Person(string n):name(n){
}
string getName(){ return name;
}
virtual int getSalary(){
}
};
class Teacher:public Person{
int salary;
public:
Teacher(string n, int sal):Person(n), salary(sal){
}
int getSalary(){
return salary+salary*0.1;
}
};
class Driver:public Person{
string name; int daily;
public:
Driver(string n, int da):Person(n), daily(da){
}
int getSalary(){
return daily*30;
}
};
class Banker:public Person{
string name; int salary;
public:
Banker(string n, int sa):Person(n), salary(sa){
}
int getSalary(){
return salary+salary*0.2;
}
};
void display(Person *ptr){
cout<<ptr->getName()<<" ***** "<<ptr->getSalary()<<endl;
}
int main (){
Teacher tchr("Mujahid", 100000);
Driver dr("Ali", 2500);
Banker bnkr("Ahmad", 90000);
display(&tchr);
display(&bnkr);
display(&dr);
return 0;
}