//: C12:AutomaticOperatorEquals.cpp // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt #include using namespace std; class Cargo { public: Cargo& operator=(const Cargo&) { cout << "inside Cargo::operator=()" << endl; return *this; } }; class Truck { Cargo b; }; int main() { Truck a, b; a = b; // Prints: "inside Cargo::operator=()" } ///:~