It sounds like you're talking about local variables. The answer is yes, they are cleaned up automatically. That is why RAII works, and how CornedBee's and my solutions are preferred in C++ over the idea of a finally block.Originally Posted by maxorator
Dynamic memory, file handles, socket connections and many many other things are not cleaned up automatically. That is why you use RAII.
Maybe, but most of the time you let your smart_ptr handle the delete for you.Originally Posted by Mario F.