#include <iostream>
#include <string>
#include <memory>

struct A : std::enable_shared_from_this<A>
{
    ~A(){std::cout<<"abc"<<std::endl;}
};

int main()
{
    A* a = new A;
    std::shared_ptr<A> p1(a);
    std::shared_ptr<A> p2(a);

    // both p1 and p2 will delete the object a
}