// File: ex5-1.cpp #include using namespace std; class Thing { private: int x; double y; public: Thing(int arg1 = 0, double arg2 = 0.0); // constructor void copyThing(Thing&); void printThing(void) { cout << x << ' ' << y << endl; } }; Thing::Thing(int arg1, double arg2) : x(arg1), y(arg2) { } void Thing::copyThing(Thing& z) { if (this == &z) { cout << "Don't copy me to myself\n"; return; } x = z.x; y = z.y; } int main(void) { Thing a(5,3.14); Thing b(1); Thing c; a.printThing(); b.printThing(); c.printThing(); c.copyThing(a); // copy Thing-a to c c.printThing(); b.copyThing(b); // copy Thing-b to b b.printThing(); }