What are destructors?
Page 1 of 1
What are destructors?
Destructors are complements of constructors. When an object is destroyed, its destructor is automatically called. Destructors are mainly useful for doing the clean up job. E.g. an object may have allocated some memory during its lifetime; destructors are the place where this memory is deallocated. Or an object may need to close some files by releasing its handles which it had previously obtained.
Destructor function has same name as that of a constructor; but the name is preceded by a tilde (‘~’) sign.
Similar topics
» What is virtual constructors/destructors?
» What are the restrictions apply to constructors and destructors?
» What are the restrictions apply to constructors and destructors?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|