home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_09 / allison / testrat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-10  |  518 b   |  29 lines

  1. #include <iostream.h>
  2. #include "rational.h"
  3.  
  4. main()
  5. {
  6.     Rational x, y(4), z(5,7);
  7.  
  8.     x = 3;
  9.     cout << "x == " << x << endl;
  10.     cout << "y == " << y << endl;
  11.     cout << "z == " << z << endl;
  12.  
  13.     cout << "x + y == " << x + y << endl;
  14.     cout << "y - z == " << y - z << endl;
  15.     cout << "x * 2 == " << x * 2 << endl;
  16.     cout << "2 / y == " << 2 / y << endl;
  17.     return 0;
  18. }
  19.  
  20. /* Output:
  21. x == 3 / 1
  22. y == 4 / 1
  23. z == 5 / 7
  24. x + y == 7 / 1
  25. y - z == 23 / 7
  26. x * 2 == 6 / 1
  27. 2 / y == 1 / 2
  28.  
  29.