File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ using namespace std;
5
5
class father {
6
6
public:
7
7
int height;
8
- father (int h ) {
9
- height = h ;
8
+ father () {
9
+
10
10
cout<<" Father constructor called" <<endl;
11
11
12
12
}
@@ -23,9 +23,9 @@ class father {
23
23
class mother {
24
24
public :
25
25
string skincolor;
26
- mother (string iscolor) {
26
+ mother () {
27
+
27
28
28
- skincolor = iscolor;
29
29
cout<<" Mother constructor called" <<endl;
30
30
}
31
31
@@ -38,11 +38,18 @@ class mother {
38
38
39
39
40
40
// multiple inheritence
41
- class child : public father , public mother {
41
+ class child : private father , private mother {
42
42
43
43
public :
44
+ // making the base class members public in derived class
45
+ father::height;
46
+ father::getHt;
47
+ mother::getColor;
48
+ mother::skincolor;
44
49
// 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;
46
53
cout<<" Child constructor called" <<endl;
47
54
48
55
}
You can’t perform that action at this time.
0 commit comments