Home » Value ptr stdendl ptr

Value ptr stdendl ptr

Stdendl ptr is automatically destroyed here stdshared_ptr Represents shared ownership of a resource. Uses reference counting to track the number of shared_ptr instances pointing to the same resource. The resource is destroyed when the last shared_ptr pointing to it is destroyed. cpp Copy code include memory include iostream void.

 

SharedPtr Example stdshared

ptrint ptr stdmake_sharedint stdshared_ptrint ptr ptr stdcout Value ptr stdendl ptr is destroyed here Rich People Number but the resource is not because ptr still points to it stdcout destroyed here and the resource is also destroyed stdweak_ptr Used in conjunction with shared_ptr. Provides a nonowning weak.

电话号码列表

Reference to an object managed

By shared_ptr. Does not contribute to the reference count thus avoiding circular references. cpp China Phone Number Copy code include memory include iostream void weakPtr Example stdshared_ptrint ptr stdmake_sharedint stdweak_ptrint weakPtr ptr if auto sharedPtr weakPtr.lock stdcout Value sharedPtr stdendl else.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *