Answer Posted / pankajkolte
Virtual Destructor is used basically to ensure proper the
sequence of call to destructor.
class Employee {
virtual ~Employee() {}
};
class Manager : public Employee {
~Manager() {}
}
Employee * m = new Manager();//here was the mistake
delete m; // <-
In this case base class destructor if marked as virtual so
as derived class destructor will get called first then base
class destructor.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Is abstract thinking intelligence?
Why do we use polymorphism?
What is the types of inheritance?
Whats is abstraction in oops?
Advantage and disadvantage of routing in telecom sector
What are two types of polymorphism?
program for insertion ,deletion,sorting in double link list
Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.
Why do we use class in oops?
What are the three main types of variables?
What is the difference between inheritance and polymorphism?
What is the difference between procedural programming and oops?
What are the three parts of a simple empty class?
What are properties in oop?
How is polymorphism achieved?