home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX1123.CPP
- // main program to exercise I/O facilities in Fraction classs
- //---------------------------------------------------------------
-
- // files in this example:
- // %F,15,EX11231.H%EX11231.H definition of the class Fraction
- // %F,15,EX11231.CPP%EX11231.CPP member functions of the class Fraction
- // EX1123.CPP this file
- //-------------------------------------------------------------
-
- #include "EX11231.H"
- #include <iostream.h>
-
- //-------------------------------------------------------------
- const int nfrac = 4; // 4 fraction objects
-
- //--------------------------------------------------------------
-
- void main()
- { Fraction f[nfrac]; // in array for convenience
- // user input values for Fraction objects
- int i;
- cout << "Enter 4 fractions (e.g. 1/2 -4/6 3 8/5 ): ";
- for ( i = 0; i < nfrac; i++)
- cin >> f[i]; // overloaded >>
- // echo these values
- for ( i = 0; i < nfrac; i++)
- cout << " Here is fraction " << i << ": " << f[i]
- << endl;
- // prompt to return to tutorial
- cout << "Press any key to return to tutorial." << endl;
- }
-
- //---------------------------------------------------------------
-