While reading about smart pointers, especially in the case of std::shared_ptr
& std::weak_ptr
, I have often found people using the term "ownership" or "it owns the object". But what exactly is this ownership? It's even more confusing while trying to understand the use-case of std::weak_ptr
!
If we write int a = 2
then can we say a owns 2
? or
To be more specific, in int a = 2; int* ptr_a = &a;
, can we say ptr_a
owns a
?