std::shared_ptr

A smart pointer in C++ that allows multiple pointers to own and manage the same object. Uses reference counting to track how many pointers currently refer to that object; once the last pointer is destroyed or reassigned (the count reaches zero), the object is automatically deleted and its memory is freed.

Reference Counting: Each std::shared_ptr holds two pointers internally: one to the managed object and one to a “control block” containing the reference count.