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

  1. // \EXAMPLES\EX1123.CPP
  2. //  main program to exercise I/O facilities in Fraction classs
  3. //---------------------------------------------------------------
  4.  
  5. //  files in this example:
  6. // %F,15,EX11231.H%EX11231.H       definition of the class Fraction
  7. // %F,15,EX11231.CPP%EX11231.CPP     member functions of the class Fraction
  8. // EX1123.CPP      this file
  9. //-------------------------------------------------------------
  10.  
  11. #include "EX11231.H"
  12. #include <iostream.h>
  13.  
  14. //-------------------------------------------------------------
  15. const int nfrac = 4;                // 4 fraction objects
  16.  
  17. //--------------------------------------------------------------
  18.  
  19. void main()
  20. {  Fraction f[nfrac];               // in array for convenience
  21. // user input values for Fraction objects
  22.   int i;
  23.   cout << "Enter 4 fractions (e.g.  1/2  -4/6  3  8/5 ):  ";
  24.   for ( i = 0; i < nfrac; i++)
  25.     cin >> f[i];                         // overloaded >>
  26. // echo these values
  27.   for ( i = 0; i < nfrac; i++)
  28.          cout << " Here is fraction " << i << ": " << f[i]
  29.               << endl;
  30. // prompt to return to tutorial
  31.   cout << "Press any key to return to tutorial." << endl;
  32. }
  33.  
  34. //---------------------------------------------------------------
  35.