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

Differentiate between a constructor and a method in C++.

550


What does #define mean in c++?

601


What are literals in C++?

585


What c++ is used for?

575


what is upcasting in C++?

711






How many ways can a variable be initialized into in C++?

590


what are Operators and explain with an example?

697


What is c++ try block?

572


Explain shallow copy?

606


Is c++ an integer?

568


What does namespace mean in c++?

545


When should overload new operator on a global basis or a class basis?

604


What is the difference between object-oriented programming and procedural programming?

686


Why is c++ still used?

593


How can I learn dev c++ programming?

555