home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX0904.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-27  |  828 b   |  31 lines

  1. // \EXAMPLES\EX0904.CPP
  2.  
  3. //---------------------------------------------------------
  4. // files in this example:
  5. // %F,15,EX0900.H%EX0900.H      definition of Fraction class
  6. // %F,15,EX0900.CPP%EX0900.CPP    Fraction members & friends
  7. // EX0904.CPP    this file
  8. //---------------------------------------------------------
  9.  
  10. #include <iostream.h>
  11. #include "EX0900.H"
  12.  
  13. void main ()
  14. {
  15.    Fraction w, x(0.5), y(1.5); // create three fractions
  16.    w = y - x;                  // subtraction of fractions
  17.    cout << "1.5 - 0.5 is: ";
  18.    cout << w;
  19.    cout << endl;
  20.  
  21.    w = x.operator-( y);    // call member subtraction operator
  22.    cout << "0.5 - 1.5 is: ";
  23.    cout << w;
  24.    cout << endl;
  25.  
  26.    w = y - 0.5;                // mixed mode arithmetic
  27.    cout << "1.5 - 0.5 is: ";
  28.    cout << w;
  29.    cout << endl;
  30. }
  31.