条款十 令 operator = 返回一个 reference to *this

条款九跳过了,里面的内容和我看到的内容有些出入,所以跳过

 

条款十  令operator = 返回一个 reference to *this

赋值操作=有时候用于连续的赋值操作,为了类能够连续赋值,并且高效完成
可以使用 reference,重载操作符时,令返回值为reference *this
class Test
{
public:
Test& operator = (const Test& obj)
{
......
return *this;
}
}

可以使用所有的相关的运算操作符

 

 

posted @ 2012-07-27 16:47  bizhu  阅读(176)  评论(0编辑  收藏  举报