Thread: destructor and how to use it

  1. #1
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715

    destructor and how to use it

    How can I call destructor to free memory after I don't need objects anymore?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How can I call destructor to free memory after I don't need objects anymore?
    C doesn't have destructors, you would have to program it yourself or use C++ which you're probably doing. But to answer your question and save you from reposting in the C++ forum, destructors are called automatically when the enclosing scope of an object is exited. For dynamically allocated objects, using delete also calls the destructor.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed