home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_01 / 1001098a < prev    next >
Text File  |  1991-11-17  |  318b  |  22 lines

  1.  
  2. Listing 8
  3.  
  4. //
  5. // operator+=
  6. //
  7. rational &rational::operator+=(rational r)
  8.     {
  9.     num = num * r.denom + r.num * denom;
  10.     denom *= r.denom;
  11.     return *this;
  12.     }
  13.  
  14. //
  15. // operator+ written in terms of operator+=
  16. //
  17. rational rational::operator+(rational r)
  18.     {
  19.     rational result(*this);
  20.     return result += r;
  21.     }
  22.