Study
C++ · Smart pointers
unique_ptr for single ownership, shared_ptr with reference counting, weak_ptr to break cycles, and make_unique/make_shared.
- unique_ptr has exactly one owner and can only be moved, never copied.
- shared_ptr frees the object when the last owner goes away, which is like Python's reference counting.