Can destructors not be initialized? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Can destructors not be initialized?

If destructors can't be initialized, then what is the essence of ~CLASS ?

5th Apr 2018, 4:26 PM
Abraham N. Mulbah
Abraham N. Mulbah - avatar
2 Answers
+ 1
Destructor gets called automatically when program ends or '}' closing bracket is encounter. Hence, there is no need for calling Destructor. Working : Destructor is a special member function whose task is to destroy the object created by constructor.
24th Apr 2018, 12:45 PM
Jayesh Patil
Jayesh Patil - avatar
0
A destructor will be executed when a object gets deleted
5th Apr 2018, 4:49 PM
Aaron Eberhardt
Aaron Eberhardt - avatar