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