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

  1. // \EXAMPLES\EX0924.CPP
  2.  
  3. //---------------------------------------------------------
  4. // files in this example:
  5. // %F,15,EX0920.H%EX0920.H      definition of Fraction class
  6. // %F,15,EX0920.CPP%EX0920.CPP    Fraction members & friends
  7. // EX0924.CPP    this file
  8. //---------------------------------------------------------
  9.  
  10. #include <iostream.h>
  11. #include "EX0920.H"
  12.  
  13. void main ()
  14. {
  15.    Fraction w, x(0.5), y(1.5);// create two fractions
  16.    w = y - x;               // implicit subtraction of Fractions
  17.    cout << "1.5 - 0.5 is: ";
  18.    cout << w;
  19.    cout << endl;
  20.  
  21.    w = operator-(x, y);     // call friend function
  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.