#include // for std::cout, std::endl #include // for std::unique_ptr #include // for EXIT_SUCCESS void Leaky() { int *x = new int(5); // heap-allocated (*x)++; std::cout << *x << std::endl; } // never used delete, therefore leak void NotLeaky() { std::unique_ptr x(new int(5)); // wrapped, heap-allocated (*x)++; std::cout << *x << std::endl; } // never used delete, but no leak int main(int argc, char **argv) { Leaky(); NotLeaky(); return EXIT_SUCCESS; }