在operator=最前面需要进行“证同测试”达到“自我赋值”的检验目的:
Widget& Widget::operator=(const Widget &rhs)
{
if (this == &rhs) return *this;
delete pb;
pb = new Bitmap(*rhs.pb);
return *this;
}
当编写一个copying函数,请确保:
原文:http://blog.csdn.net/chfe007/article/details/44679573