effective c++ 条款10 handle assignment to self operator =

非强制性,但是个好习惯

当使用连锁赋值时很有用

x=y=z=10;

class Window
{
  public:
    Window& operator=(int size)
    {
     ...
     return *this;
    }
}

这个规则适用于 -,+, +=,-= etc 

posted @ 2014-07-05 03:42  williamwood  阅读(175)  评论(0)    收藏  举报