How do you know that your class needs a virtual destructor?
Answer Posted / abc
When We Declare a Virtual Function In Base Class.
The Base Class Pointer Can Point To Derived Class objects.
And If we Try To Delete The Base Class Pointer ,it will Call
the base Class Destructor(Which Is Wrong).
To Handle Such Scenario,The Base Class Destructor need To
Be Declared As Virtual(Which Makes All The Derived Class
Destructors Virtual).Now The Base Class Pointer Will Call
The Respective Destructors(Ofcourse,It Is Decided at Run
Time.With The Virtual Mechanism.)
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is a constructor in c++ with example?
Why cstdlib is used in c++?
How is new() different from malloc()?
Describe the advantages of operator overloading?
write a corrected statement in c++ so that the statement will work properly. x = y = z + 3a;
What is object in c++ example?
Keyword mean in declaration?
What is a multiset c++?
What is data type in c++?
What is a constant? Explain with an example.
How is computer programming useful in real life?
What is the full form of c++?
What are separators in c++?
What is the array and initializing arrays in c++?
Can malloc be used in c++?