← Back to Templates
Question 742
Show Two Values of Different Types
Show Two Values of Different Types
Write a function template showPair(T first, U second) with TWO type parameters. It prints first, one space, second, then a newline.
T and U are deduced separately from the two arguments, so they may be different types or the same type. The tests call showPair(3, 2.5), showPair('x', 10), showPair(std::string("age"), 21) and showPair(5, 6), printing one line each.
Do NOT write a main function.
Expected Output:
3 2.5 x 10 age 21 5 6
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Templates
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.