I disagree. You can overload destructor's because you need to make them virtual as well so the destructor's are called. A difference between a destructor and other member functions is that, if a regular member function has a body at the derived class, only the version at Derived class gets executed. Whereas in case of destructors, both derived as well as base class versions get executed.
Try Running the program Code: #include <iostream.h> class Base { public: Base(){ cout<<"Constructor: Base"<<endl;} ~Base(){ cout<<"Destructor : Base"<<endl;} }; class Derived: public Base { public: Derived(){ cout<<"Constructor: Derived"<<endl;} ~Derived(){ cout<<"Destructor : Derived"<<endl;} }; void main() { Base *Var = new Derived(); delete Var; } and then add the virtual to the base class and run and see what is the difference. Which means when you override the class constructor and destructor and by default inherited and overloaded.
Bro ! I am asking about Destructor Overloading same as we do with the Constructor.. Like Multiple Constructors in a class with different argument. But your example is about Virtual Destructor.. If I'm wrong, rectify me.
What I have given as a code is also for overloading destructor but it looks like what you are looking for is whether we can define more than one destructor in a class or not ? The answer is no for couple of reason. 1. Syntax wise we cannot have them as you cannot have params in the destructor 2. Semantically you don't need to clean up the object in more than one ways.
Shabbir ! According to your code, we are defining the destructor as virtual but what is the difference in defining a normal function as virtual and destructor as virtual. Actually we define a virtual destructor so that complete memory can be released or because of security reasons like avoiding memory leaks.... I wasn't aware it is called Destructor Overloading....
shabbir, the example that you have posted is not of destructor overloading... and even in the case when u redefine a member function of the base class in the derived class, it is called function overriding..