A smart pointer is an object that dynamically allocates memory for the thing that it points to, and when the smart pointer goes out of scope, it automatically frees memory for what it points to. This is useful when you want something that is freed when it goes out of scope but is too large to be put on the stack (or there are other problems that prevent it from being pushed onto the stack).
Reinderien
source share