CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List
C++ Code Walkthrough #85

Deduce Two Independent Types

easyTemplates

📄 Code

Read carefully — what does this print?
1#include <iostream>
2#include <string>
3 
4template <typename T, typename U>
5void showPair(T first, U second) {
6 std::cout << first << " " << second << "\n";
7}
8 
9int main() {
10 showPair(3, 4.5);
11 showPair('x', 10);
12 showPair(std::string("age"), 21);
13 showPair(2.5, 1.5);
14 showPair(1, 2);
15 return 0;
16}

🎯 Your Answer