#include #include "./ToyPtr.h" // Simple struct to illustrate "->" operator. typedef struct Pt_st { int x = 1, y = 2; } Point; std::ostream &operator<<(std::ostream &out, const Point &rhs) { return out << "(" << rhs.x << "," << rhs.y << ")"; } int main(int argc, char **argv) { // Create a dumb pointer. Point *leak = new Point; // Create a "smart" pointer. (OK, it's still pretty dumb.) ToyPtr notleak(new Point); ToyPtr test(nullptr); // Use them. std::cout << " *leak: " << *leak << std::endl; std::cout << " leak->x: " << leak->x << std::endl; std::cout << " *notleak: " << *notleak << std::endl; std::cout << "notleak->x: " << notleak->x << std::endl; // Return, leaking "leak" but not "notleak". return 0; }