-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtest2.cpp
More file actions
45 lines (43 loc) · 746 Bytes
/
test2.cpp
File metadata and controls
45 lines (43 loc) · 746 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
#include<iostream>
using namespace std;
class base{
public:
int b;
base(int x){cout<<"\nbase constructor\n";
b=x;
}
~base(){cout<<"\nbase destrcutor\n";
}
};
class der1 : public base{
public:
int d1;
der1(int x,int y):base(x){cout<<"\nder1 constructor\n";
d1=y;
}
~der1(){cout<<"\nder1 destructor\n";
}
};
class der2 : public der1{
public:
int d2;
der2(int x,int y,int z):der1(x,y){cout<<"\nder2 constructor\n";
d2=z;
}
~der2(){cout<<"\nder2 destructor\n";
}
};
//class comb : public der1,public der2{
// int c;
// public:
// comb(){cout<<"\ncomb constructor\n";
// }
// ~comb(){cout<<"\ncomb destructor\n";
// }
//};
int main()
{
der2 ob(1,2,3);
cout<<ob.b<<endl<<ob.d1<<endl<<ob.d2;
return 0;
}