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 does it mean when someone says I oop?
How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction
How do you define social class?
What is encapsulation c#?
What is polymorphism what are the different types of polymorphism?
What is encapsulation with real life example?
Prepare me a program for the animation of train
Why we use classes in oop?
What is multilevel inheritance in oop?
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!!!)
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
What is inheritance in simple words?
Where is pseudocode used?
What are the benefits of oop?
What are the features of oop?