Pure virtual destructor ?
-
HI, What is pure virtual destructor? what is the use of using pure virtual destructor ? Thanks, Krish.
-
HI, What is pure virtual destructor? what is the use of using pure virtual destructor ? Thanks, Krish.
See, for instance, the competitors...[^]. Personally, I think you should always use virtual destructors. No need to have pure virtual destructors (see [^]).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
HI, What is pure virtual destructor? what is the use of using pure virtual destructor ? Thanks, Krish.
-
HI, What is pure virtual destructor? what is the use of using pure virtual destructor ? Thanks, Krish.
A pure virtual destructor is any destructor marked as virtual with = 0 after it's signature, e.g:
class T
{
public:
virtual ~T() = 0;
};Making a destructor pure virtual means very little more than making the destructor virtual (and you do that to make sure the correct destructor is called when you delete an object through a base class pointer). The additional bit is that it means the derived class has to define it's own destructor and not rely on the base class one. One additional wrinkle is that all pure virtual destructors have to have an implementation, unlike normal pure virtual member functions which don't have to have one. Cheers, Ash