Given template <typename T> T mx(T a, T b), what happens with the call mx(3, 2.5)?
Correct answer D. Compilation fails because T is deduced as both int and double
Explanation
Template argument deduction is done separately for each function argument, and the results must agree. Here the first argument deduces T = int and the second T = double, so deduction fails and no implicit conversion is attempted. You can fix it with an explicit argument, mx(3, 2.5), or by casting one argument so both types match.
Answer checked How we write and check questions
Discussion