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

  1. // \EXAMPLES\EX0905.CPP
  2.  
  3. //---------------------------------------------------------
  4. // files in this example:
  5. // %F,15,EX0900.H%EX0900.H      definition of Fraction class
  6. // %F,15,EX0900.CPP%EX0900.CPP    Fraction members & friends
  7. // EX0905.CPP    this file
  8. //---------------------------------------------------------
  9.  
  10. #include <iostream.h>
  11. #include "EX0900.H"
  12.  
  13. void main()
  14. {
  15.    Fraction a, b(.25), c(0.5); // create Fraction objects
  16.  
  17.    cout << "The initial value of a is: ";
  18.    cout << a;
  19.    cout << endl;
  20.  
  21.    cout << "The initial value of b is: ";
  22.    cout << b;
  23.    cout << endl;
  24.  
  25.    cout << "The initial value of c is: ";
  26.    cout << c;
  27.    cout << endl << endl;
  28.  
  29.    a = b;                     // assign fraction a to fraction b
  30.    cout << "         The value of  a = b  is: ";
  31.    cout << a;
  32.    cout << endl;
  33.  
  34.    a.operator=(c);            // call assignment operator
  35.    cout << "The value of  a.operator=(c)  is: ";
  36.    cout <<a;
  37.    cout << endl;
  38. }
  39.