-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb57.cpp
More file actions
39 lines (30 loc) · 739 Bytes
/
b57.cpp
File metadata and controls
39 lines (30 loc) · 739 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
#include <iostream> // DESTRUCTORS
using namespace std; // DESTRUCTORS NEITHER TAKES AN ARGUMENT NEITHER RETURN ANY VALUE
int count = 0;
class num
{
public:
num()
{
count++;
cout << "this is the time when constructor is called for object" << count << endl;
}
~num() // DESTRUCTOR
{
cout << "this is the time when my detsructor is called " << count << endl;
count--;
}
};
int main()
{
cout << "creating first object " << endl;
num n1;
{
cout << "entering this block" << endl;
cout << "creating two more objects" << endl;
num n2, n3;
cout << "exiting this block";
}
cout << "Back to main function" << endl;
return 0;
}