I have a Fraction class that I want to be able to typecast to a double. Is there a way to write that explicitly? (Like operator overloading)
This is my constructor:
Fraction::Fraction(double n, double d) : numerator(n), denominator(d)
{
if (d == 0) throw Error::DIVIDE_BY_ZERO;
}
When overloading operators, e.g.:
bool operator==(const Fraction& left, const Fraction& right)
I want that overload to be able to take a double
as well without having to write overloads with (const Fraction&, const double)
and (const double, const Fraction&)