0
what is the destructor
2 Réponses
+ 6
A destructor is a little similar to a constructor.
A constructor will run code when an object is instantiated, but a destructor will run code when an object is destroyed. This happens when the scope of an object runs out.
Ex: If you make an object in a method, and then leave the method, the destructor will trigger.
+ 3
A destructor is a special method called automatically during the destruction of an object. Actions executed in the destructor include the following: Recovering the heap space allocated during the lifetime of an object. Closing file or database connections. Releasing network resources.