when can we use virtual destructor?

Answer Posted / achal ubbott

We should know the proper sequence of calling of
destructors.
1. destructor of derived.
and then
2. destructor of base.

but if base* bptr = new derived();

then
delete bptr;

can behave wrong and violate the sequence. got it?

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What c++ library is string in?

580


Is java the same as c++?

547


What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random

655


What is c++ & why it is used?

592


Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list

613






What is difference between rand () and srand ()?

594


What is a unnitialised pointer?

532


Differentiate between structure and class in c++.

602


Does improper inheritance have a potential to wreck a project?

630


Differences between private, protected and public and give examples.

577


What can I use instead of namespace std?

643


How do you show the declaration of a virtual constructor?

530


Explain object slicing in c++?

587


How can you link a c program with a c function?

567


What is difference between array and vector in c++?

559