#ifndef FEETINCHES_H #define FEETINCHES_H #include using namespace std; // A class to hold distances or measurements // expressed in feet and inches. class FeetInches { private: int feet; int inches; void simplify(); public: FeetInches(int f = 0, int i = 0) { feet = f; inches = i; simplify(); } void setData(int f, int i) { feet = f; inches = i; simplify(); } int getFeet() { return feet; } int getInches() { return inches; } // Overloaded operators. FeetInches operator +(const FeetInches &) const; FeetInches operator - (const FeetInches &) const; FeetInches operator++(); FeetInches operator++(int); bool operator>(const FeetInches &) const; bool operator<(const FeetInches &) const; bool operator==(const FeetInches &) const; friend ostream &operator<<(ostream &, FeetInches &); friend istream &operator>>(istream &, FeetInches &); // Operator converts to type double (feet with fraction). operator double() { return feet + inches/12.0; } // Operator converts to type int by discarding inches. operator int() { return feet; } }; #endif