Cplusplus.
resource. The resource is deallocated only when the last std::shared_ptr pointing to it is destroyed or reset. std::shared_ptr<int> sharedPtr1(new int(20)); std::shared_ptr<int> sharedPtr2 = sharedPtr1; // Both point to the same integer. std::weak_ptr: Complements std::shared_ptr by providing a