Consider mathematical operations in a language like C++, which supports
both overloading and coercion. In many cases, it may make sense to provide multiple, overloaded versions of a function, one for each numeric type
or combination of types. In other cases, we might use a single version—
probably defined for double-precision floating point arguments—and rely
on coercion to allow that function to be used for other numeric types (e.g.,
integers). Give an example in which overloading is clearly the preferable
approach. Give another in which coercion is almost certainly better.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here