CJCoding With Joseph
15free / daySign inCreate account

Print Any Value with One Template

Write a function template printValue(T value) with one type parameter. It prints the value it receives and then a newline.

One template replaces a separate function for every type: the compiler makes the version it needs from the type of the argument. The tests call printValue with an int, a double, a char, a std::string and then another int, so five lines are printed in that order.

Do NOT write a main function.

Expected Output:

42
2.5
A
hello
7

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
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.