更新时间:2022-05-17 02:27:07
遵循良好的约定,以与operator=
的内置类型的行为保持一致.
That is a good convention to follow to be consistent with the behavior of operator=
for built-in types.
对于内置类型,您可以执行以下操作:
With built-in types you can do something like this:
int a, b, c;
// ...
a = b = c = 10;
如果您不将引用返回给*this
,则您的类型将不支持分配链.
If you do not return the reference to *this
, the assignment chain won't be supported by your type.