author:
- luixiao1223
title: ‘operator=返回*this’
tips
- 连锁赋值
int x,y,z;
x=y=z=15;
- 赋值采用右结合
x=(y=(z=15));
例子
Widget& operator=(const Widget& rhs) {
return *this;
}
class Widget {
public:
Widget& operator+=(const Widget& rhs)
{
return *this;
}
Widget& operator=(int rhs)
{
return *this;
}
};