forked from wadehuber/codeexamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdestructor.cpp
More file actions
40 lines (29 loc) · 749 Bytes
/
Copy pathdestructor.cpp
File metadata and controls
40 lines (29 loc) · 749 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
#include<iostream>
using namespace std;
class Destruct {
public:
int a;
Destruct(int x=0) : a(x) {
cout << "Constructor " << a << endl;
}
~Destruct() {
cout << "Destructor " << a << endl;
}
};
void destFunction(Destruct d3) {
Destruct d4(4);
cout << "In dest function" << endl;
}
int main() {
cout << "Start of main" << endl;
Destruct d1(1);
Destruct d2(2);
Destruct * d5 = new Destruct(5);
cout << "Done declaring variables" << endl;
cout << endl << "Calling destFunction(d1)" << endl;
destFunction(d1);
cout << endl << "Calling delete(d5)" << endl;
delete(d5);
cout << endl << "End of main" << endl;
return 0;
}