home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0902.CPP
-
- //---------------------------------------------------------
- // files in this example:
- // %F,15,EX0900.H%EX0900.H definition of Fraction class
- // %F,15,EX0900.CPP%EX0900.CPP Fraction members & friends
- // EX0902.CPP this file
- //---------------------------------------------------------
-
- #include <iostream.h>
- #include "EX0900.H"
-
- void main()
- {
- Fraction y, a(1.5), b(3.0); // create three fractions
- y = a + b; // add two fractions
- cout << "1.5 + 3.0 = ";
- cout << y;
- cout << endl;
-
- y = b - a; // subtract two fractions
- cout << "3.0 - 1.5 = ";
- cout << y;
- cout << endl;
-
- y = a * a; // multiply two fractions
- cout << "1.5 * 1.5 = ";
- cout << y;
- cout << endl;
-
- y = b / a; // divide one fraction by another
- cout << "3.0 / 1.5 = ";
- cout << y;
- cout << endl;
-
- }