// This program demonstrates the FeetInches class's // overloaded math and relational operators. #include #include "feetinch4.h" using namespace std; int main() { FeetInches first, second, third; int f, i; //Demonstrating overload + and - operators cout << "Demonstrating overlaoded + and - operators.\n"; cout << "Enter a distance in feet and inches: "; cin >> f >> i; first.setData(f, i); cout << "Enter another distance in feet and inches: "; cin >> f >> i; second.setData(f, i); third = first + second; cout << "first + second = "; cout << third.getFeet() << " feet, "; cout << third.getInches() << " inches.\n"; third = first - second; cout << "first - second = "; cout << third.getFeet() << " feet, "; cout << third.getInches() << " inches.\n"; cout << endl; //Demonstrating overload prefix ++ operator cout << "Demonstrating overlaoded prefix ++ operator.\n"; for (int count = 0; count < 12; count++) { first = ++second; cout << "first: " << first.getFeet() << " feet, "; cout << first.getInches() << " inches. "; cout << "second: " << second.getFeet() << " feet, "; cout << second.getInches() << " inches.\n"; } //Demonstrating overload postfix ++ operator cout << "\nDemonstrating overloaded postfix ++ operator.\n"; for (int count = 0; count < 12; count++) { first = second++; cout << "first: " << first.getFeet() << " feet, "; cout << first.getInches() << " inches. "; cout << "second: " << second.getFeet() << " feet, "; cout << second.getInches() << " inches.\n"; } cout << endl; //Demonstrating overload relational operators cout << "Demonstrating overlaoded relational operators.\n"; cout << "Enter a distance in feet and inches: "; cin >> f >> i; first.setData(f, i); cout << "Enter another distance in feet and inches: "; cin >> f >> i; second.setData(f, i); if (first == second) cout << "First is equal to second.\n"; if (first > second) cout << "First is greater than second.\n"; if (first < second) cout << "First is less than second.\n"; return 0; }