CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #115

Two Arguments That Disagree About T

easyTemplates

This program does not compile. Why does the call add(2, 3.5) fail?

📄 Code

1#include <iostream>
2 
3template <typename T>
4T add(T a, T b) {
5 return a + b;
6}
7 
8int main() {
9 std::cout << add(2, 3.5) << "\n";
10 return 0;
11}