Question.15
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
It defaults to int for all templates
Template argument deduction -- the compiler deduces T=int from the argument types (10 and 20 are both int)
The return type int forces T=int
Compilation error -- template arguments must be explicit