File tree 1 file changed +74
-0
lines changed
1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < string>
3
+ using namespace std ;
4
+
5
+ class A
6
+ {
7
+
8
+ public:
9
+ A ()
10
+ {
11
+ cout << " A CONSTRUCTOR CALLED " << endl;
12
+ }
13
+
14
+ virtual ~A ()
15
+ {
16
+ cout << " A DESTRUCTOR CALLED " << endl;
17
+ }
18
+ };
19
+
20
+ class P
21
+ {
22
+
23
+ public:
24
+ P ()
25
+ {
26
+ cout << " p CONSTRUCTOR CALLED " << endl;
27
+ }
28
+
29
+ virtual ~P ()
30
+ {
31
+ cout << " A DESTRUCTOR CALLED " << endl;
32
+ }
33
+ };
34
+
35
+ class B
36
+ {
37
+
38
+ public:
39
+ A objA;
40
+ P *ptr;
41
+
42
+ B ()
43
+ {
44
+ cout << " B CONSTRUCTOR CALLED " << endl;
45
+ }
46
+
47
+ virtual ~B ()
48
+ {
49
+ cout << " B DESTRUCTOR CALLED " << endl;
50
+ }
51
+ };
52
+
53
+ class C : public B
54
+ {
55
+
56
+ public:
57
+ C ()
58
+ {
59
+ cout << " C CONSTRUCTOR CALLED " << endl;
60
+ }
61
+
62
+ virtual ~C ()
63
+ {
64
+ cout << " C DESTRUCTOR CALLED " << endl;
65
+ }
66
+ };
67
+
68
+ int main ()
69
+ {
70
+
71
+ B *objB = new C;
72
+ delete objB;
73
+ return 0 ;
74
+ }
You can’t perform that action at this time.
0 commit comments