问题代码: //错误 inline const rational& operator*(const rational& lhs, const rational& rhs) { rational result(lhs.n * rhs.n, lhs.d * rhs.d); return result; } //极容易内存漏露 inline const rational& operator*(const rational& lhs, const rational& rhs) { rational *result = new rational(lhs.n * rhs.n, lhs.d * rhs.d); return *result; } 修改后代码: inline const rational operator*(const rational& lhs, const rational& rhs) { return rational(lhs.n * rhs.n, lhs.d * rhs.d); }