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
Define upcasting.
Is rust better than c++?
Is atoi safe?
What is c++ course?
What is a catch statement?
Which software is best for programming?
What are friend classes?
Is dev c++ free?
What is the use of pointer in c++ with example?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
What should main() return in c and c++?
Explain the use of virtual destructor?
Write a function to find the nth item from the end of a linked list in a single pass.
How c functions prevents rework and therefore saves the programers time as wel as length of the code ?
Can you help me with this one? Make a program that when a user inputed a Product Name, it will display its price, and when the user inputed the quantity of the inputed product, it will show its total price. The output must be like this: Product Name: Price: Quantity: Total Price: ..this is the list of products to be inputed: Cellphone - 1500 Washing Machine - 5200 Television - 6000 Refrigirator - 8000 Oven - 2000 Computer - 11000 thanks..:D