`

     1  #include "fraction.h"
     2
     3  int main()
     4  {
     5     // Test constructors
     6     Fraction a; // Value is 0/1
     7     Fraction b(4); // Value is 4/1
     8     Fraction c(6,8); // Value is 6/8, which is converted to 3/4
     9     cout << "Constructed values " << a << " " << b << " " << c << "\n";
    10     Fraction d(c); // Value is copy of c, also 3/4
    11     cout << "Value of d is " << d.numerator() << "/"
    12        << d.denominator() << "\n";
    13     // Test arithmetic instructions
    14     d = b + c;
    15     cout << "4 + 3/4 is " << d << "\n";
    16     d = b - c;
    17     cout << "4 - 3/4 is " << d << "\n";
    18     Fraction e = (b + (-c));
    19     cout << e << "Done with negation\n";
    20     if (d == e)
    21        cout << "Subtraction test successful\n";
    22     else
    23        cout << "Subtraction test failed\n";
    24     a = Fraction(6,8);
    25     b = Fraction(7,8);
    26     if (a < b)
    27        cout << "Compare successful\n";
    28     return 0;
    29  }

`