home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0904.CPP
-
- //---------------------------------------------------------
- // files in this example:
- // %F,15,EX0900.H%EX0900.H definition of Fraction class
- // %F,15,EX0900.CPP%EX0900.CPP Fraction members & friends
- // EX0904.CPP this file
- //---------------------------------------------------------
-
- #include <iostream.h>
- #include "EX0900.H"
-
- void main ()
- {
- Fraction w, x(0.5), y(1.5); // create three fractions
- w = y - x; // subtraction of fractions
- cout << "1.5 - 0.5 is: ";
- cout << w;
- cout << endl;
-
- w = x.operator-( y); // call member subtraction operator
- 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;
- }
-