operator - method

Rat operator -(
  1. Rat other
)

Subtracts other from this Rat.

Implementation

Rat operator -(Rat other) {
  if (d == other.d) {
    return Rat(n - other.n, d);
  }
  return Rat(n * other.d - other.n * d, d * other.d);
}