Chapter 17: Problem 2
We have used three kinds of absolute value function: abs, labs, and fabs. These functions differ only in the type of their argument. It might be better to have a function template for the absolute value function. Give a function template for an absolute value function called absolute. The template will apply only to types for which \(<\) is defined, for which the unary negation operator is defined, and for which the constant \(\theta\) can be used in a comparison with a value of that type. Thus, the function absolute can be called with any of the number types, such as int, long, and double. Give both the function declaration and the function definition for the template.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.