Smart pointers are pointers that own the object they point to and automatically destroy the object they point to and deallocate the memory once the pointers go out of scope. This way, we do not have to manually delete the object, which was the case with the new and delete operators.
Smart pointers are declared in the <memory> header. We will cover the following smart pointers – unique and shared.