Yes, you do. I would delete as soon as it is no longer used.Quote:
Originally Posted by HelpMeC
All non-static local variables would be destroyed, and that includes class instances. But again, what you have here is an ordinary pointer that is the non-static local variable. So, the pointer will be destroyed, but not what it points to, unless you manually do that yourself.Quote:
Originally Posted by HelpMeC
This is why we use smart pointers like std::unique_ptr instead: when the unique_ptr is destroyed because it falls out of scope, what it points to is also destroyed, so we don't have to manually destroy it.