Skip to content

Unified assignment operator

这是在 stackoverflow What are move semantics? # part two # Special member functions 中提出的:

X& X::operator=(X source)    // unified assignment operator
{
    swap(source);            // see my first answer for an explanation
    return *this;
}

它有利也有弊:

弊端:

1、子类中,如果要调用基类的operator=,要如何实现呢?