若operator=不返回此类型,则当进行连续赋值时会出现问题:
int x,y,z;
x=y=z=15;
对于任何运算符重载函数,最好都返回一个referrnce to *this。
总结
1.令赋值操作符返回一个reference to *this。
若operator=不返回此类型,则当进行连续赋值时会出现问题:
int x,y,z;
x=y=z=15;
对于任何运算符重载函数,最好都返回一个referrnce to *this。
1.令赋值操作符返回一个reference to *this。