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 #114

Choosing the Type Yourself

easyTemplates

The call writes the template argument explicitly: larger<double>(3, 4.5). What happens?

📄 Code

1#include <iostream>
2 
3template <typename T>
4T larger(T a, T b) {
5 if (a > b) {
6 return a;
7 }
8 return b;
9}
10 
11int main() {
12 std::cout << larger<double>(3, 4.5) << "\n";
13 return 0;
14}