Destructure | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Destructure

destructure can call only one time but what we have to delete multiple objects at different time ( first u delete some objects and now u have to delete some more objects)?

28th Feb 2017, 5:52 PM
Posi2
Posi2 - avatar
3 Answers
+ 3
Generally speaking, you won't need to call the destructor explicitly –memory is freed when the object is no longer used. If you do need to manually free memory, take a look at "delete" keyword.
28th Feb 2017, 6:04 PM
Álvaro
+ 2
first of all, it's destructor not destructure..(not trying to be a jerk, but that just changes the whole meaning) second, each object is a seperate instance of the class, therefore each object has a seperate instance of the destructor declared in the class which gets called when that object is destroyed, not any other object.
28th Feb 2017, 6:03 PM
Nikunj Arora
Nikunj Arora - avatar
+ 2
default destructor delete objects so no need for programmers destructor
28th Feb 2017, 7:23 PM
Posi2
Posi2 - avatar