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 an iterator class in c++?
Is c++ a good beginners programming language?
Can member data be public?
Explain the concept of friend function in c++?
What does new in c++ do?
What is private public protected in c++?
Which software is best for c++ programming?
List different attributes in C++?
Define anonymous class.
Is nan a c++?
Write a program using display() function which takes two arguments.
Why cout is used in c++?
What are static and dynamic type checking?
Mention the storage classes in c++.
Is java a c++?