Answer Posted / kamil mohamed
virtual destructor is recommended when you want to destroy
(delete) an object through it's parent pointer. This good
habit enforces proper cleanup of derived classes
Example:
class Employee {
virtual ~Employee() {}
};
class Manager : public Employee {
~Manager() {}
}
Manager * m = new Employee();
delete m; // <--
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
What are the 3 principles of oop?
Can we create object of abstract class?
How to call a non virtual function in the derived class by using base class pointer
What is the diamond problem in inheritance?
What are the advantages of polymorphism?
What is encapsulation in simple terms?
What does oop mean in snapchat?
What is the difference between a constructor and a destructor?
What does and I oop mean?
What is the purpose of enum?
What is polymorphism in oop example?
How do you explain polymorphism?
c++ program to swap the objects of two different classes
Which language is not a true object oriented programming language?