记住:
为实现“连锁赋值”,赋值操作符必须返回一个reference指向操作符的左侧实参。
class Widget { public: ... Widget& operator=(const Widget& rhs) { ... return *this; //返回左侧对象 } Widget& operator+=(const Widget& rhs) { ... return *this; } Widget& operator=(int rhs) { ... return *this; } };