when you allocate memory on the heap with new/new[] the instance persists through-out any scope but the catch is your responsible to give the memory back by explicitly calling delete/delete[].
But when you have lots of raw pointers refering to the same instance on the heap its diffcult to know when to delete. Also if store pointers to heap memory in STL containers then STL containers can't delete heap allocated memory for you, you have to iterate throught the container and explicitly call delete on each element.
This is the point of
smart pointers in general and particularly shared_ptr it knows when & how to delete memory for you even in STL containers.
statically allocated memory gets automatically cleaned-up as soon as it goes out of scope so there isn't much point in using smart pointers with them. There are times thou that you wont a smart pointer to statically allocated memory and if that really is the case for you then you need to give shared_ptr a special "null deleter" type that doesn't try to call delete on statically allocated memory:
struct null_deleter { void operator()(void const *) const {}};int main() { Entity p; shared_ptr<Entity> p_ptr(&p, null_deleter()); return 0;}