-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance_exercise.cpp
More file actions
47 lines (46 loc) · 913 Bytes
/
inheritance_exercise.cpp
File metadata and controls
47 lines (46 loc) · 913 Bytes
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
#include<iostream>
#include<string>
using namespace std;
class Employee
{
private:
int eid;
string name;
public:
Employee(int e,string n)
{
eid=e;
name=n;
}
int getEmployeeID(){return eid;}
string getName(){return name;}
};
class FullTimeEmployee:public Employee
{
private:
int salary;
public:
FullTimeEmployee(int e,string n,int s):Employee(e,n)
{
salary=s;
}
int getSalary(){return salary;}
};
class PartTimeEmployee:public Employee
{
private:
int wage;
public:
PartTimeEmployee(int e,string n,int w):Employee(e,n)
{
wage=w;
}
int getWage(){return wage;}
};
int main()
{
FullTimeEmployee e1(1,"Rohan",25000);
PartTimeEmployee e2(2,"Soham",3000);
cout<<"salary of "<<e1.getName()<<" is "<<e1.getSalary()<<endl;
cout<<"salary of "<<e2.getName()<<" is "<<e2.getWage()<<endl;
}