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 object in c++?
What is operators in c++?
Explain the difference between abstract class and interface in c++?
Why c++ is called oop?
If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?
How does the copy constructor differ from the assignment operator (=)?
Why is c++ still used?
What do you mean by static variables?
What are separators in c++?
Can a class be static in c++?
What are friend functions in C++?
What is an operator function? Describe the function of an operator function?
What is input operator in c++?
What is the equivalent of Pascal's Real a) unsigned int b) float c) char
When should we use multiple inheritance?