This is not a creature that you should worry about, it is a deletion.
With smart pointers (type of reference counting), objects can usually be several other objects, and when the last link goes out of scope, the object is automatically deleted. That way, you no longer have to manually delete anything, you can only leak memory when you have circular dependencies and your objects are never deleted from behind.
The type for only one owner ( std::auto_ptr ) also frees you from your legal capacity, but it allows only one owner at a time (although ownership can be transferred). This is useful for objects that you pass as pointers, but you still want them to be automatically cleaned when they go out of scope (so that they work well in containers, and stack reversal in case of exception works as expected).
In any case, smart pointers make explicit ownership of your code not only for you and your teammates, but also for the compiler - improper execution will likely result in a compiler error or a runtime error that is relatively simple to catch the protective encoding. In the memory-driven manual code, it is easy to get the ownership situation somewhere wrong (due to incorrect reading of comments or assuming something is in the wrong way), and the resulting error is usually difficult to track - you will be a memory leak, overwriting what is not yours, the program accidentally crashes, etc .; they all have in common that the situation in which the error occurs is not related to the violation code section.
source share