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 are shallow and deep copies?

821


Explain the difference between static and dynamic binding of functions?

760


Why can templates only be implemented in the header file?

844


What does override mean in c++?

759


In the derived class, which data member of the base class are visible?

832






What is the best c++ compiler for windows 10?

748


What is capacity in vector in c++?

728


How do you save a c++ program?

742


Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?

1770


What do you know about near, far and huge pointer?

775


What is the latest c++ standard?

866


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

740


What is fixed in c++?

745


How would perform Pattern Matching in C++?

907


Why is c++ difficult?

781