destructor and how to use it

This is a discussion on destructor and how to use it within the C Programming forums, part of the General Programming Boards category; How can I call destructor to free memory after I don't need objects anymore?...

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

    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,796
    >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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21