File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed
Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < iostream>
2+
3+ using namespace std ;
4+
5+ class father {
6+ public:
7+ int height;
8+ father (int h) {
9+ height = h ;
10+ cout<<" Father constructor called" <<endl;
11+
12+ }
13+
14+ void getHt () {
15+ cout<<" Height is " <<height<<endl;
16+ }
17+
18+
19+
20+
21+ };
22+
23+ class mother {
24+ public :
25+ string skincolor;
26+ mother (string iscolor) {
27+
28+ skincolor = iscolor;
29+ cout<<" Mother constructor called" <<endl;
30+ }
31+
32+ void getColor () {
33+ cout<<" Skin color is " << skincolor<<endl;
34+ }
35+
36+
37+ };
38+
39+
40+ // multiple inheritence
41+ class child : public father , public mother {
42+
43+ public :
44+ // calling parent class constructors and passing arguments to them
45+ child (int ht,string color) : father(ht) , mother(color) {
46+ cout<<" Child constructor called" <<endl;
47+
48+ }
49+
50+ };
51+
52+
53+ int main () {
54+
55+ child c (172 ," white" );
56+ c.getColor ();
57+ c.getHt ();
58+
59+
60+
61+ return 0 ;
62+ }
You can’t perform that action at this time.
0 commit comments