-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht8.cpp
More file actions
52 lines (44 loc) · 952 Bytes
/
Copy patht8.cpp
File metadata and controls
52 lines (44 loc) · 952 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
/*
1.default visibility is private.
2. public visibility mode: public member of the base class will becomes public member of derived class.
3. private visibility mode: public member of the base class will becomes private member of the derived class.
4. private member are never inherite>
*/
#include <iostream>
using namespace std;
class employee
{
public:
int id;
float salary;
employee(int i)
{
id = i;
salary = 345.0;
}
employee(){}
};
class programmer : public employee
{
public:
int languagecode;
programmer(int i)
{
id = i;
languagecode = 56;
}
void getdata(){
cout<<id<<endl;
}
};
int main()
{
employee e1(3), e2(4);
cout << e1.salary << endl;
cout << e2.salary << endl;
programmer p(2);
cout<<p.languagecode<<endl;
cout<<p.salary<<endl;
p.getdata();
return 0;
}