// driver for problem 8.17, Deitel and Deitel #include "RationalOverloads.h" // demonstrate Rational numbers, operator overloading, etc. int main() { RationalOvld w(4), x(7,6), y(3,8), z, copy(x); cout << "The copy object looks just like its parameter, copy = " << copy << endl; z = x + y; cout << x << " + " << y << " = " << z << endl; z = w + y; cout << w << " + " << y << " = " << z << endl; z = x - y; cout << x << " - " << y << " = " << z << endl; z = x * y; cout << x << " * " << y << " = " << z << endl; z = x / y; cout << x << " / " << y << " = " << z << endl; z = x + 5; cout << x << " + " << 5 << " = " << z << endl; //ERROR -- no match for operator +(int, class RationalOvld) // z = 5 + x; z = RationalOvld(5) + x; cout << 5 << " + " << x << " = " << z << endl; //ERROR -- no match for operator -(class RationalOvld, class RationalOvld) // z -= x; cout << x << " is:" << endl; cout << ((x > y) ? " > " : " not > "); cout << y << " according to the overloaded > operator\n"; cout << ((x < y) ? " < " : " not < "); cout << y << " according to the overloaded < operator\n"; cout << ((x >= y) ? " >= " : " not >= "); cout << y << " according to the overloaded >= operator\n"; cout << ((x <= y) ? " <= " : " not <= "); cout << y << " according to the overloaded <= operator\n"; cout << ((x == y) ? " == " : " not == "); cout << y << " according to the overloaded == operator\n"; cout << ((x != y) ? " != " : " not != "); cout << y << " according to the overloaded != operator" << endl; cout << x << " + " << y; x += y; cout << " = the now changed " << x << endl; return 0; }