home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0924.CPP
-
- //---------------------------------------------------------
- // files in this example:
- // %F,15,EX0920.H%EX0920.H definition of Fraction class
- // %F,15,EX0920.CPP%EX0920.CPP Fraction members & friends
- // EX0924.CPP this file
- //---------------------------------------------------------
-
- #include <iostream.h>
- #include "EX0920.H"
-
- void main ()
- {
- Fraction w, x(0.5), y(1.5);// create two fractions
- w = y - x; // implicit subtraction of Fractions
- cout << "1.5 - 0.5 is: ";
- cout << w;
- cout << endl;
-
- w = operator-(x, y); // call friend function
- cout << "0.5 - 1.5 is: ";
- cout << w;
- cout << endl;
-
- w = y - 0.5; // mixed mode arithmetic
- cout << "1.5 - 0.5 is: ";
- cout << w;
- cout << endl;
- }
-