Skip to content

Commit 35b85ec

Browse files
committed
implementing protected inheritence
1 parent 8c5d03d commit 35b85ec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

publicInheritence.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ using namespace std;
66
class Shape {
77

88
protected:
9-
int side;
109

11-
public:
1210

11+
public:
12+
int side;
1313
int getArea();
1414
int volume();
1515
};
1616

1717

1818
//PUBLIC inheritence-public members of parent class act as public members of child class 2) Protected member of parent class, as protected member of child class
1919

20-
class square : public Shape {
20+
class square : protected Shape {
2121
public:
2222
//constructor
2323
square(int a) {
@@ -41,7 +41,7 @@ class square : public Shape {
4141

4242
int main () {
4343

44-
square s(4); //object of subclass
44+
square s(10); //object of subclass
4545
s.getArea();
4646
s.perm();
4747
s.volume();

0 commit comments

Comments
 (0)