how to count the number of objects created in c++
pls explain with a simple example
You have to overload the new and delete operators to count memory allocations.
void * operator new (size_t size) { void * p = malloc (size); num_allocations++; return p; } void operator delete (void * p) { num_deletions++; free (p); }