How can I call destructor to free memory after I don't need objects anymore?
Printable View
How can I call destructor to free memory after I don't need objects anymore?
>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.