/* A program to show an assignment overload */ #include #include using namespace std; class Person { public: string name; Person& operator= (const Person &p); // This is the prototype for the assignment overload. }; /* Here's the assignment overload -- it just copies the name (which is what would have happened if I didn't define the assignment overload, and prints out that it has been called. */ Person& Person::operator= (const Person &p) { name = p.name; cout << "Assignment Overload" << endl; return *this; } int main() { Person c1, c2; c1.name = "Jim"; c2 = c1; cout << c2.name << endl; return 0; }