Explain the need for "Virtual Destructor"?
Answer Posted / lylez00
If A is a base class, and from that, B is derived, and a
dynamically allocated object of type B is deleted via a
pointer of type A, then B's destructor will not be invoked
unless A's destructor is virtual.
A *a = new B();
delete a; // won't invoke B's destructor unless A's
destructor is virtual
Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
Can we sort map in c++?
What are the uses of c++ in the real world?
How do you compile the source code with your compiler?
What is the difference between strcpy() and strncpy()?
Who created c++?
What is the latest c++ standard?
Describe exception handling concept with an example?
What is algorithm in c++ programming?
What is the use of endl in c++ give an example?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
What is the c++ code?
What is the difference between prefix and postfix versions of operator++()?
What are the uses of pointers?
Can char be a number c++?
What is a class template?