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 NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
List the special characteristics of constructor.
Can you explicitly call a destructor on a local variable?
What is the difference between an external iterator and an internal iterator?
Why are pointers not used in c++?
How would you implement a substr() function that extracts a sub string from a given string?
Const char *p , char const *p What is the difference between the above two?
What is #include sstream?
What are the uses of c++ in the real world?
What is the best way to take screenshots of a window with c++ in windows?
What is the difference between ++ count and count ++?
What is a type library?
What is std :: endl?
What are iterators in c++?
Is c++ a good beginners programming language?