D
Dennis Lee Bieber
Ugh... Cross-posted.... And since I don't know which group
replies are being /read/ from...
have to overload for each order of arguments).
In the case of the apples/oranges, one could also create a
"FruitBasket" type, then overload
function "+"(left:apples; rightranges) return FruitBasket
and
function "+"(leftranges; right:apples) return FruitBasket
You would, inside of these overloads, have to "convert" apples
and oranges to base numeric types, do the addition on that, then
"convert" the result to FruitBasket.
For your length and weight, add a torque type, and define the
proper operator
function "*"(left:length; right:weight) return torque
--
replies are being /read/ from...
Only if you've defined an overloaded "*" operator (and you alsoI like that idea. It is possible using templates, of course. Is it general
enough? If you replace "apples" with "weight" and "oranges" with "length",
is it then permissible to multiply a length with a weight but not add the
two together?
have to overload for each order of arguments).
In the case of the apples/oranges, one could also create a
"FruitBasket" type, then overload
function "+"(left:apples; rightranges) return FruitBasket
and
function "+"(leftranges; right:apples) return FruitBasket
You would, inside of these overloads, have to "convert" apples
and oranges to base numeric types, do the addition on that, then
"convert" the result to FruitBasket.
For your length and weight, add a torque type, and define the
proper operator
function "*"(left:length; right:weight) return torque
--