-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathInheritance CPP
More file actions
71 lines (57 loc) · 1006 Bytes
/
Inheritance CPP
File metadata and controls
71 lines (57 loc) · 1006 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
using namespace std;
class employee
{
private:
int eid;
string name;
public:
employee(int id,string n)
{
eid=id;
name=n;
}
int getid()
{
return eid;
}
string getname()
{
return name;
}
};
class fulltimeemployee: public employee
{
private:
int salary;
public:
fulltimeemployee(int id,string n,int sal):employee(id,n)
{
salary=sal;
}
int getsalary()
{
return salary;
}
};
class parttimeemployee: public employee
{
private:
int wages;
public:
parttimeemployee(int id,string n,int w): employee(id,n)
{
wages=w;
}
int getwages()
{
return wages;
}
};
int main()
{
fulltimeemployee p1(1,"umesh",100000);
parttimeemployee p2(2,"Navya",100000);
cout<<"Salary of"<<p1.getname()<<" is "<<p1.getsalary()<<endl;
cout<<"Daily wage of "<<p2.getname()<<" is "<<p2.getwages()<<endl;
}