#include #include "ToyPtr.h" using std::cout; using std::endl; using std::ostream; // Simple struct to illustrate "->" operator. typedef struct Pt_st { 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. Point* leak = new Point; // 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 << " leak->x: " << leak->x << endl; cout << " *notleak: " << *notleak << endl; cout << "notleak->x: " << notleak->x << endl; // Return, leaking "leak" but not "notleak". return EXIT_SUCCESS; }