const Rational& operator(const Rational& lhs, const Rational& rhs)
{
Rational* result = new Rational(lhs.n*rhs.n, lhs.d*rhs.d);
return *result;
}
【Effective C++】必须返回对象时,别妄想返回引用
最新推荐文章于 2023-11-28 23:34:19 发布
const Rational& operator(const Rational& lhs, const Rational& rhs)
{
Rational* result = new Rational(lhs.n*rhs.n, lhs.d*rhs.d);
return *result;
}