Skip to content

Commit a56e79c

Browse files
committed
changes to the multiple inheritence
1 parent ceb0ea9 commit a56e79c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

multipleInheritence.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ using namespace std;
55
class father {
66
public:
77
int height;
8-
father(int h) {
9-
height = h ;
8+
father() {
9+
1010
cout<<"Father constructor called"<<endl;
1111

1212
}
@@ -23,9 +23,9 @@ class father {
2323
class mother {
2424
public :
2525
string skincolor;
26-
mother(string iscolor) {
26+
mother() {
27+
2728

28-
skincolor = iscolor;
2929
cout<<"Mother constructor called"<<endl;
3030
}
3131

@@ -38,11 +38,18 @@ class mother {
3838

3939

4040
//multiple inheritence
41-
class child: public father, public mother {
41+
class child: private father, private mother {
4242

4343
public :
44+
//making the base class members public in derived class
45+
father::height;
46+
father::getHt;
47+
mother::getColor;
48+
mother::skincolor;
4449
//calling parent class constructors and passing arguments to them
45-
child(int ht,string color) : father(ht) , mother(color) {
50+
child(int ht,string color) : father() , mother() {
51+
height=ht;
52+
skincolor=color;
4653
cout<<"Child constructor called"<<endl;
4754

4855
}

0 commit comments

Comments
 (0)