istream& operator>>(istream& in, Fraction& r) { int t, b; // Read the top in >> t; // If there is a slash, read the next number char c; in >> c; if (c == '/') in >> b; else { in.putback(c); b = 1; } r = Fraction(t, b); return in; }