+ 5

What are destructors

any relation with constructors

2nd Apr 2017, 2:35 AM
arpit dixit
arpit dixit - avatar
5 ответов
+ 9
Constructors are called when an object is created. Destructors are called when an object is deleted.
2nd Apr 2017, 2:55 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 18
They're comparable to constructors. While constructors instantiate objects, destructors delete them to free memory. In both cases, you can add code to perform extra actions before instantiation/deletion. Ex: Closing files and databases, writing to a log file, etc. An object is deleted when it leaves its scope. Ex: If you make an object in a method, that object is deleted after the method ends.
2nd Apr 2017, 2:54 AM
Tamra
Tamra - avatar
+ 8
Destructors are nothing but what destroys the scope of an object once it is no longer needed.
2nd Apr 2017, 2:58 AM
Swati
Swati - avatar
0
destructors are 360 opposite to constructor their task is to destroy the memory of object after use
12th Apr 2017, 9:18 AM
PRANJAL AGNIHOTRI
PRANJAL AGNIHOTRI - avatar
0
constructor = created destructor = deleted
29th Jul 2020, 12:30 PM
Maha SEGNI
Maha SEGNI - avatar