Fraction::operator double() const
{
// Convert numerator to double, then do division
return static_cast<double>(top) / bottom;
}
Can be used:
Fraction a(1, 2); double d = 7.0; double halfd = d * a; // a is converted to double to do multiplication cout << "one half seven is " << halfd << "\n";