Smart Pointers C++
Smart Pointers C++
------------shared pointer
can be shared
multiple owners can access
one raw pointer to multiple owners
shared_ptr<MyClass>shrd_ptr_1 = make_shared<MyClass>();
--------------
weak_ptr
if a memory location is pointed to a shared pointer it will not increase the number
of owners
weak_ptr<int> weakPtr1;
{
shared_ptr<int> s_ptr1 = make_shared<int>(25);
weakPtr1 = s_ptr1;
}