What are destructors? when are they called? what is their utility?
Answers
Answered by
2
In object-oriented programming LIKE JAVA, a destructor (dtor) is a method which is automatically invoked when the object is destroyed. It can happen when its lifetime is bound to scope and the execution leaves the scope, when it is embedded in another object whose lifetime ends, or when it was allocated dynamically and is released explicitly. ITS MAIN PURPOSE IS FOR FREE RESOURCES(memory allocations, open files or sockets, database connections, resource locks, etc.) which were acquired by the object during its life and/or deregister from other entities which may keep references to it.
Himanshu1629:
please mark me brainlist if it helped
Similar questions