Posts: 266
Threads: 239
Joined: Apr 2011
sir we can creat many constructor in a class as you said but we will pass only one distructor to all constructor . sir if we want to distruct only a perticuler constructor then what we should do . if we pass distructor then it will distruct all the constructor thanks
Posts: 9,583
Threads: 8,089
Joined: Apr 2011
As I understood the context of your question, please note that classes have multiple constructors but only one destructor. The destructor is automatically called when an object is destroyed. In the destructor all the cleaning task has been performed i.e. de-allocation of memory. When object is created, memory allocated to object through constructor. When object is destroyed, the destructor de-allocates the memory of that object. The destructor is called for all the objects in the class.