Question.7
A developer calls a template function without specifying the type:
template<typename T> T max_val(T a, T b) { return (a > b) ? a : b; } int result = max_val(10, 20); // No <int> specified
How does the compiler know T is int?
Select Answer
Defaults to int for templates
int
templates
Inferred from the return type
return
Requires explicit template arguments
explicit
Uses template argument deduction
deduction