New course! Every coder should learn Generative AI!
Try a free lesson+ 3
What is the difference between constructor and destructor??
6 Answers
+ 4
constructor is used to initialize the instance of class as he said. and destructor is when the object is deleted or destroyed which is no longer in needed
+ 2
A constructor is called when a class is created. A destructor is called when a class is destroyed.
+ 2
this is not an exact answer
+ 2
Constructor is a special member function whose task is to initialise an object of it's class.
&
Destructor is a special member function whose task is to destroy the object created by constructor.
Which gets called automatically when program ends.
+ 1
That's all I know about it. Please refer to the Q&A or the the course you took for answers.
- 1
constructor is used when we want to execute some fuction after runtime...