先看我的代码,temp是基类,first是子类;
first& first::operator=(const first & ppp){
if(&ppp == this){
return *this;
}
operator=(ppp);
}
有没有问题,肯定是有的,首先要明白opertor必须使用基类(temp)的构造函数,不能使用first的(不然就自己调用自己,无限递归了)
出错原因是这里的operator前没有加temp的定位符,正确写法
temp::operator=(ppp);
同时还要注意:不能直接*this = ppp了,这样也会导致无限递归!