+ 1
What is diffrence between constructor and destructor in C++?
Object-oriented programming
2 Réponses
+ 6
Constructor is used to initialize the instance of a class while Destructor destroys the objects when they are no longer needed.
Constructor is Called when new instance of a class is created while Destructor is called when instance of a class is deleted or released.
Constructor allocates the memory while Destructor releases the memory.
+ 1
Constructor: executed when an object is created.
Destructor: executed when an object is destroyed.
You cannot take arguments for a destructor. If you don't know what an object is yet, you don't need to worrie about these right now.