错误递归

错误递归

1
2
3
4
5
6
7
8
9
Polynomial& Polynomial::operator=(const Polynomial& p) {
if (this == &p) return *this;
delete[] coefficients;
size = p.size;
coefficients = new double[size];
for (int i = 0; i < size; i++)
coefficients[i] = p.coefficients[i];
return *this;
}
1
2
3
4
5
6
Polynomial& Polynomial::operator=(const Polynomial& p) {
if (this == &p) return *this;
delete[] coefficients;
*this = Polynomial(p);//重复调用了=
return *this;
}