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
Why do we need pointers?
Is map ordered c++?
What c++ library is string in?
What are the four partitions in which c++ compiler divides the ram?
Is c++ an integer?
What are the advantages of using friend classes?
what is scupper?
What is extern c++?
Does there exist any other function which can be used to convert an integer or a float to a string?
How we can differentiate between a pre and post increment operators during overloading?
What is the oldest programming language?
Which format specifier is used for printing a pointer value?
What is abstraction c++?
Mention the storage classes in c++.
Write a Program for find and replace a character in a string.