C++: how to use smart pointers?

Example:

int* ptr = new int(5);
Smart pointers automatically manage memory.

Solution:

std::unique_ptr ptr(new int(5));

Beginner's Guide to C++