What is virtual destructor? Why?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / mugdha taru
virtual destructor are those who can not override while
redefining derived class.
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / riya piyush jain
In object-oriented programming, a destructor (sometimes
shortened to dtor) is a method which is automatically
invoked when the object is destroyed. Its main purpose is
to clean up and to free the resources which were acquired
by the object along its life cycle and unlink it from other
objects or resources invalidating any references in the
process. The use of destructors is key to the concept of
Resource Acquisition Is Initialization.
| Is This Answer Correct ? | 4 Yes | 8 No |
What is DeadlyDiamondDeathProblem ?
What are the 4 main oop principles?
What is nutshell in programming language?
1 Answers Satyam, Tech Mahindra,
What is the difference between inheritance and polymorphism?
what is the need of abstraction? what is abstraction?what is the abstraction for stack?
to find out the minimum of two integer number of two different classes using friend function
20% of a 6 litre solution and 60% of 4 litre solution are mixed what the % of mixture of solution it is resulted into?
What Is a Polymorphism? How many types of polymorphism and whats that use in application?
Why do we use virtual functions?
How to deploy web appliction in web logic ?
What is encapsulation in simple terms?
How can we use the preprocessor #if and #elseif.