1.

Which among the following is true?(a) A class may have virtual destructor but not virtual constructor(b) A class may have virtual constructor but not virtual destructor(c) A class may have virtual constructor and virtual constructor(d) A class may have either virtual destructor or virtual constructorI had been asked this question at a job interview.My query is from Virtual Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (a) A CLASS may have virtual destructor but not virtual constructor

The explanation: Any class can CONTAIN virtual destructor. But is not possible to define a virtual constructor. The REASON behind is that the DESTRUCTORS can be overridden but CONSTRUCTORS should not be.



Discussion

No Comment Found

Related InterviewSolutions