Hi,
to practice overloading operators I'm building a Fractions class.
I have a question about comparison operators. In a tutorial, the overloaded == returned an int (1 or 0) - wouldn't it make more sense to return a bool (true or false)? Would it matter - I guess overloading these operators is important if you want to use the sort algorithm on them and such?
This is what I have to compare fractions. Is it OK?
Code:class Fraction { public: Fraction(int up = 0, int low = 1):upper(up), lower(low) {} ~Fraction() {} //.... bool operator== (const Fraction f) { if (this->upper * f.lower == this->lower*f.upper) return true; else return false; } private: int upper, lower; };