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

  1. // \EXAMPLES\EX0906.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. // EX0906.CPP    this file
  8. //---------------------------------------------------------
  9.  
  10. #include <iostream.h>
  11. #include "EX0900.H"
  12.  
  13. void main()
  14. {
  15.    Fraction a(1);     // create a Fraction object
  16.  
  17.    cout << "The initial value of a is:      ";
  18.    cout << a;
  19.    cout << endl;
  20.  
  21.    // increment Fraction a
  22.    cout << "The value of ++a is:            ";
  23.    cout << ++a;
  24.    cout << endl;
  25.  
  26.    // use the nonstatic member
  27.    cout << "The value of a.operator++() is: ";
  28.    cout << a.operator++();
  29.    cout << endl;
  30.  
  31.    cout << "The final value of a is:        ";
  32.    cout << a;
  33.    cout << endl;
  34. }
  35.