shared_ptr

A shared_ptr is a container for raw pointers. It is a reference counting ownership model, i.e. it maintains the reference count of its contained pointer in cooperation with all copies of the shared_ptr. So, the counter is incremented each time a new pointer points to the resource and decremented when the destructor of the object is called. 
An object referenced by the contained raw pointer will not be destroyed until reference count is greater than zero i.e. until all copies of shared_ptr have been deleted.
So, we should use shared_ptr when we want to assign one raw pointer to multiple owners.
```
#include <memory>
#include <iostream>
using std::cout, std::endl;
 
int main()
{
    std::shared_ptr<int> p1(new int);
    *p1 = 10;
    cout<<*p1<<endl;
    auto p11 = p1;
    cout<<*p1<<endl;
    cout<<*p11<<endl;
  
    auto p2 = std::make_shared<int[]>(10); 
    p2.get()[2] = 20;
    cout<<p2.get()[2]<<endl;
    auto p21 = p2;
    cout<<p2.get()[2]<<endl;
    cout<<p21.get()[2]<<endl;
    return 0;
}

/* Output
10
10
20
20
20
*/
```