Computer Science, asked by TRB, 9 months ago

Like constructors, can there be more than one destructors in a class?
a)
Yes
b)
No​

Answers

Answered by lohithkumar36
3

Answer:

The above answer is no or option b)

Answered by RitaNarine
0

b) No (Not possible)

  • Destructor destroys the class objects created by constructor.
  • Destructor has the same name as their class name preceded by a tilde (~) symbol.
  • It is not possible to define more than one destructor.
  • The destructor is only one way to destroy the object create by constructor. Hence destructor can-not be overloaded.
  • Destructor neither requires any argument nor returns any value.
  • It is automatically called when object goes out of scope.
  • Destructor release memory space occupied by the objects created by constructor.
  • In destructor, objects are destroyed in the reverse of an object creation

The thing is to be noted here, if the object is created by using new or the constructor uses new to allocate memory which resides in the heap memory or the free store, the destructor should use delete to free the memory.

Hence, b) NO

Similar questions