13.8练习的答案代码中有一个地方不太明白:
HasPtr& operator=(const HasPtr &hp) {
std::string *new_ps = new std::string(*hp.ps);
delete ps;
ps = new_ps;
i = hp.i;
return *this;
}
在ps=new_ps;
之前ps指针就已经delete了啊,为什么之后ps又被赋值了?本人cpp小白。。。。望大牛指教