Wednesday 22 February 2012

Is it possible to overload the destructor of a class? | Constructor in C++

 No, the destructor of a class cannot be overloaded. We can have only one destructor for a class, called class name ::~ destructor name(). For example, for a class named fruit, the syntax is - fruit::~ fruit(). It never takes any parameters and it never returns anything.
We cannot pass parameters to the destructor anyway, since you never explicitly call a destructor.