-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrackObjects.cpp
52 lines (50 loc) · 1.11 KB
/
trackObjects.cpp
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
/**
* @file trackObjects.cpp
* @author Rohit,Rohit ([email protected])
* @brief Program to keep a track of no. of objects created, destroyed and active in the program.
* @version 0.1
* @date 2021-12-28
*
* @copyright Copyright (c) 2021
*
*/
#include <iostream>
using namespace std;
int obj, des, actv;
class trackObjects
{
public:
trackObjects()
{
obj++;
cout << "\n-------------------------------------------";
cout << "\nObject " << ++actv << " created." << endl;
}
~trackObjects()
{
des++;
cout << "\nObject " << actv-- << " destroyed." << endl;
show();
}
void show()
{
int count = obj;
cout << "\nNo. of Objects Created = " << obj;
cout << "\nNo. of Objects Active = " << actv;
cout << "\nNo. of Objects Destroyed = " << des << endl;
}
};
int main()
{
{
trackObjects t1;
t1.show();
{
trackObjects t2;
t2.show();
}
}
trackObjects t3;
t3.show();
return 0;
} // end of main()