1.

Which among the following is correct for the destructors concept?(a) Destructors can be overloaded(b) Destructors can have only one parameter at maximum(c) Destructors are always called after object goes out of scope(d) There can be only one destructor in a classThe question was asked in an interview.I would like to ask this question from Destructors in section Constructors and Destructors of Object Oriented Programming

Answer»

The CORRECT choice is (d) There can be only one destructor in a class

The explanation is: This is so because the DESTRUCTORS can’t be OVERLOADED. And the destructor must have the same name as that of class with a tilde symbol preceding the name of the destructor. Hence there can be only one destructor in a class. Since more than one FUNCTION with same name and signature can’t be PRESENT in same scope.



Discussion

No Comment Found

Related InterviewSolutions