C ++ smart pointers personal record

shared_ptr allow multiple pointers to the same object, unique_ptr the "exclusive" object points. The library also defines a class named weak_ptr along, which is a weak reference to an object managed by shared_ptr, three smart pointers are defined in the memory header file in.

Weak_ptr shared_ptr not use or point to a unique_ptr, since the latter is exclusively their own, can not share with others.

shared_ptr and unique_ptr operations:




 weak_ptr operations:



Weak_ptr which introduced a circular reference is to solve the problem, paste-speaking smart pointers history and what is the link circular references:



Guess you like

Origin www.cnblogs.com/FdWzy/p/12424189.html