-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinheritance4.cpp
More file actions
53 lines (49 loc) · 795 Bytes
/
Copy pathinheritance4.cpp
File metadata and controls
53 lines (49 loc) · 795 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
//wap to inherite properties of multiple Base Classes
#include<iostream>
using namespace std;
class base1
{
int i=0;
public:
base1(int x)
{
i=x;
cout<<"Base1 contructor"<<endl;
cout<<"i="<<i<<endl;
}
~base1()
{
cout<<"Base1 destructor"<<endl;
}
};
class base2
{
int i=0;
public:
base2(int x)
{
i=x;
cout<<"Base2 constructor"<<endl;
cout<<"i="<<i<<endl;
}
~base2()
{
cout<<"Base2 destructor"<<endl;
}
};
class derived:public base1,public base2
{
public:
derived(int x,int y):base1(x),base2(y)
{
cout<<"Derived constructor"<<endl;
}
~derived()
{
cout<<"Derived destructor"<<endl;
}
};
int main()
{
derived ob(10,3);
}