auto_ptr,scoped_ptr,shared_ptr,weak_ptr
auto_ptr,scoped_ptr,shared_ptr,weak_ptr The use of auto_ptr is very simple. You have ownership of a dynamically allocated object through the constructor, and then it can be used as an object pointer. When the auto_ptr object is destroyed, it will also automatically destroy the object it owns. release can be used to manually give up ownership, and reset can be used to manually destroy internal objects. But in fact, auto_ptr is a class that is quite easy to be misused and is often misused in practice. The reason is due to its object ownership nature and its non-trivial copy behavior. The object ownership of auto_ptr is exclusive! This determines that it is impossible for two auto_ptr objects to have ownership of the same dynamic object at the same time, which also leads to the non-equivalent copy behavior of auto_ptr, which is accompanied by the transfer of object ownership. At the same time, do not put auto_ptr into the container of the standard library, otherwise the unprepared copy behavior of the standard library container (the copy behavior required by the standard library container is equivalent) will lead to errors that are difficult to detect. The special copy behavior of auto_ptr makes it a very…