-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccessModifiers.cpp
More file actions
67 lines (52 loc) · 1014 Bytes
/
accessModifiers.cpp
File metadata and controls
67 lines (52 loc) · 1014 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
#include<iostream>
using namespace std;
class human{
protected:
int weight;
public:
int height;
int age;
string name;
int getAge(){
return age;
}
void setWeight(int w){
this-> weight = w;
}
};
class male : public human{
public:
int colour;
void sleep(){
cout << "Male sleeping..." << endl;
}
};
class male2 : protected human{
public:
int colour;
void sleep(){
cout << "Male sleeping..." << endl;
}
int getHeight(){
return height;
}
};
class male3 : private human{
public:
int colour;
void sleep(){
cout << "Male sleeping..." << endl;
}
};
int main(int argc, char const *argv[])
{
male m1;
male2 m2;
male3 m3;
cout << m1.height<< endl;
// cout << m1.weight<< endl; not possible
// cout << m2.height<< endl; not possible
cout << m2.getHeight() << endl;
// cout << m3.height<< endl; not possible
return 0;
}