-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut19.cpp
53 lines (44 loc) · 864 Bytes
/
tut19.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 Employee;
// BASIC INHERITANCE
class Employee
{
int id;
public:
int salary;
Employee(int v1)
{
id = v1;
salary = 34;
}
Employee() {}
void show(void)
{
cout << id << endl;
cout << "Hello Employee!!" << endl;
}
};
class Programmer : public Employee // <-- private of Employee will never come here and by default every thing comes from Employee as private and to make public of Employee , write public here for Employee
{
int coder;
public:
Programmer(int v1)
{
coder = v1;
};
void show(void)
{
cout << coder << endl;
cout << "Hello Programmer!!" << endl;
}
};
int main()
{
Employee a(2);
a.show();
Programmer ankit(1);
ankit.show();
cout << ankit.salary;
return 0;
}