What is virtual destructor? Why?
Answer Posted / sagarika patra
When a destructor is declared as virtual in the base class
is known as virtul destructor.
Whenever any object of derived class of base type is freed
(using delete operator),the destructor of the derived class
is called and the memory allocated by derived class
variables are freed ,leaving the memory allocated by the
base class variables as unfreed.
Hence by declaring the base class destructor as
virtual,both the destructor will called in order.
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
What is polymorphism in oops with example?
What is a null tree?
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
What is difference between pop and oop?
Why is polymorphism important in oop?
• What are the desirable attributes for memory managment?
What is class and example?
What are classes oop?
What is polymorphism programming?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< Will I be able to get a picture in D drive to the c++
program? If so, help me out? What is the real time example of inheritance? Is this job good for future?
can do this job post grduate student? What is coupling in oop? What is static modifier?