Question: 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
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.
Step by Step Solution
3.35 Rating (164 Votes )
There are 3 Steps involved in it
Consider a function to return the lesser of two floatingpoint arguments double mindouble x double y ... View full answer
Get step-by-step solutions from verified subject matter experts
