abstract destructor

V

Victor Bazarov

Tony said:
When should an abstract destructor be used.

Let me point out that there is no term "abstract destructor". You can
have a virtual destructor declared pure (just like any other virtual
function), which would make your /class/ abstract. The destructor is
still just 'pure' in that case.

Assuming the conversation is about a pure virtual destructor, the answer
is: when you have no other virtual member functions you want to declare
pure, and you still want your class to be abstract.

V
 
J

Jerry Coffin

Hello!!


Is it possible to have abstract destructor.

Hopefully you really mean virtual destructor. In that case, the
answer is yes. A virtual destructor is necessary if you might ever
delete an instance of a derived class via a pointer or reference to
the base class.

Alternatively, you might mean a pure virtual destructor, which would
make this an abstract base class. In that case the answer is still
yes. The same condition as above applies here as well, but in this
case (is with any other pure virtual function) the function must be
overridden in some derived class for objects to be instantiated. IOW,
just like any other Abstract Base Class, this one can't be
instantiated itself -- it just defines an interface that will be
supported by derived classes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,064
Members
47,672
Latest member
svaraho

Latest Threads

Top