-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut36.cpp
More file actions
44 lines (42 loc) · 767 Bytes
/
tut36.cpp
File metadata and controls
44 lines (42 loc) · 767 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
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
// Base Class
class Employee
{
public:
int id;
float salary;
Employee(int inpId)
{
id = inpId;
salary = 34.0;
}
Employee() {}
};
// Creating a Programmer class derived from Employee Base class
class Programmer : public Employee
{
public:
int languageCode;
Programmer(int inpId)
{
id = inpId;
languageCode = 9;
}
void getData(){
cout<<id<<endl;
}
};
int main()
{
Employee harry(1), rohan(2);
cout << harry.salary << endl;
cout << rohan.salary << endl;
Programmer skillF(10);
cout << skillF.languageCode<<endl;
cout << skillF.id<<endl;
skillF.getData();
return 0;
}