Many may be wondering why you need to make a destructor private. After all you created it for divine uses such as returning the used resources back to the resource pool which protect you from memory leaks and dangling pointers. Then why do you want to torture yourself by making it private and unavailable.
The answer to the above questions becomes clear in the following scenarios..
Scene1:-When you want to create non inheritable-Final Classes
It could happens that you want your class not to be inherited by any other class i.e., to create a final class. For making a class final all you have to do is make the class’s constructor or destructor private. Since in a class there can be any number of constructors where as it can have only one destructor, it’s easy to keep the single destructor as private and make the class Final
Scene2:-While using Reference Counting Objects
As you have guessed what a reference counting object is, its an object that tracks the number of references to itself, and destroys itself when none of the references point toward it. Making it simple, the object may be in use by more than one reference simultaneously. Imagine the situation in which the destructor of this object is public and as one of the refrence is released which innocently calls the destructor which is public and destroys the object. This could result in situations like the object being destroyed and other references still pointing to our dead object. To avoid such situations we make the destructor private and provide alternate function which will be careful enough to invoke the destructor only if the reference count is 0.
class ABC
{
private:
int RefCount;
~ABC();
public:
ABC();
void incRefCount() { ++RefCount; }
void decRefCount() { if (–RefCount <=0) delete this; }
};
This class definition is just for the purpose of demonstrating what a reference counting object’s class would look like. It can be further enhanced by avoiding situations like multiple calls to decrefCount(),and can be even restructured by deriving the class using a friend class.

