See what I have done, I have allocated memory ptrs onto the list but I have failed to delete the contents. Is there any chance that the STL list is smart enough to deallocate the ptrs for me? If not, what do I need to do to deallocate them?
Is there any chance that the STL list is smart enough to deallocate the ptrs for me?
That would be a very silly thing for the list to do for you; it has no way of knowing when you are done with the object and it can be safely deleted.
A very simple solution is to use a shared pointer. When using a shared pointer, the object will be automatically deleted when nobody has a copy of the pointer anymore.
It's up to you to ensure that you don't delete the object and then try to use the naked pointer to access it, but that's true of every pointer and you already have to think about that.