what is virtual destructor

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


Please Help Members By Posting Answers For Below Questions

write a program to find 2 power of a 5digit number with out using big int and exponent ?

1899


How many human genes are polymorphic?

577


What is abstract class in oop?

537


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

1794


Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box

2038






write string class as your own class in java without using any built-in function

1980


What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?

2110


any one please tell me the purpose of operator overloading

1967


What is cohesion in oop?

624


write a programe to calculate the simple intrest and compund intrest using by function overlading

1670


Is oop better than procedural?

576


What are different oops concepts?

578


What is coupling in oop?

601


Why do we use oops?

595


What is inheritance and how many types of inheritance?

623