Should i always use smart pointer in C++ 11
c++, c++11, shared-ptr
Solution
It is hard to imagine situations where you would want to manually delete an object, so in that sense, the answer to your question is "yes, always use smart pointers".
However, raw pointers do have another use case. Smart pointers are all about conferring ownership semantics. A `unique_ptr` has exclusive ownership of the object it points to, and will destroy the object when the pointer goes out of scope. A `shared_ptr` implements shared ownership, and the object will be destroyed when the last shared pointer goes out of scope.
Raw pointers are still useful for cases where you want to point to an object without indicating any kind of ownership. You're just pointing to an object you know exists, and that someone else (who owns it) will delete it when the time comes.
Raw pointers are for pointing to objects. Smart pointers are for owning objects.
Problem
From c++ 11 i can write code without create and deleting raw pointers. But is it the right way to go- Should i always use smart pointers (either shared, unique or weak) or are there situations in which i should delete objects by myself?