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
how to access grid view row?
Does a derived class inherit or doesn't inherit?
What is the array and initializing arrays in c++?
What it is and how it might be called (2 methods).
What do you mean by function and operator overloading in c++?
Describe the setting up of my member functions to avoid overriding by the derived class?
Why c++ is better than c language?
List different attributes in C++?
What is conditions when using boolean operators?
Difference between Abstraction and encapsulation in C++?
How many ways can a variable be initialized into in C++?
What is the full form of india?
How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?
why is iostream::eof inside a loop condition considered wrong?
Write a program to find the reverse Fibonacci series starting from N.