Farewell to new and delete

C++11 introduced several smart pointers (residing in the <memory> header): std::shared_ptr: retains shared ownership of an object, that is destroyed when the last shared_ptr that holds a reference to it is destroyed or assigned another pointer. std::unique_ptr: retains sole ownership of an object, that is destroyed when the unique_ptr goes out of scope std::weak_ptr: retains … Read more