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

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