J
jraul
Suppose you have a complex number class, and you overload conversions
to double by only taking the real part. You also overload operator* to
do complex multiplication.
You then write:
complex a(...);
complex b(...);
complex c = a*b;
Then the compiler complains that it is ambiguous because it doesn't
know if you want complex*complex, or to do the case to double first,
and do double*double. I would think that it would be obvious that
complex*complex should be chosen. Other than explicit casts is there a
way to handle this?
to double by only taking the real part. You also overload operator* to
do complex multiplication.
You then write:
complex a(...);
complex b(...);
complex c = a*b;
Then the compiler complains that it is ambiguous because it doesn't
know if you want complex*complex, or to do the case to double first,
and do double*double. I would think that it would be obvious that
complex*complex should be chosen. Other than explicit casts is there a
way to handle this?