Can any clearly explain constructor and destructors concept? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can any clearly explain constructor and destructors concept?

Always had difficulty with these topics

21st Nov 2016, 4:01 PM
Abhishek Gedam
Abhishek Gedam - avatar
1 Answer
+ 3
A constructor is run when an object is created (often used for initialisation), and can be overloaded. The destructor is run when an object is destroyed (often use for clean-up). A class can only have one destructor.
21st Nov 2016, 4:08 PM
Cohen Creber
Cohen Creber - avatar