Base classes destructors

N

Nuno Barros

Cn someone tell me if when i call the destructor of a derivated class,
the destructor of the base class is called implicitly?

Or shall i call the destructor by myself?

Thanks in advance

Nuno Barros
 
K

Kurt Krueckeberg

Cn someone tell me if when i call the destructor of a derivated class,
the destructor of the base class is called implicitly?

Or shall i call the destructor by myself?
The base destructor will be called implicitly after the derived constructor
completes; you don't have to call it.
 
R

Ron Natalie

Nuno Barros said:
Cn someone tell me if when i call the destructor of a derivated class,
the destructor of the base class is called implicitly?

Destructors for the base classes and member objects are called automatically
(after the destructor body of the derived class is run).
 
B

Buster Copley

Buster said:
Provided the destructor is declared virtual in the base class, the less-
derived classes' destructors will be invoked when the more-derived
classes' destructors are completed.

I should have paused for thought, I've got it all backwards. Virtual
destructors are for deleting derived-class objects through base-class
pointers. The other posts are correct. Sorry!
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top