I have a question about overloaded operators...
I am working on a Rational (fraction) class, and I have the operators
working fine for Rational -> Rational functions, but I want to be able
to also work with Integers and Doubles.
What would be better (and/or easier)?
Overload Operator_Add and Operator_AddRight (and all other math
operators) or should I overload the Operator_Convert?
An Integer would and can be easily promoted to a Rational... a double
is more tricky. I would rather promote the Rational to a double, but I
would still need to be able to demote a double into a Rational if that
is the type which the data is being stored as.
Given this formula:
ratB = ratA + 3
Do I have to have an Operator_Add(Integer) or will
Operator_Convert(Integer) work? What about:
ratB = 3 + ratA
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|