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

Deduce a Single Template Type

easyTemplates

📄 Code

Read carefully — what does this print?
1#include <iostream>
2#include <string>
3 
4template <typename T>
5void printValue(T value) {
6 std::cout << value << "\n";
7}
8 
9int main() {
10 printValue(42);
11 printValue(2.5);
12 printValue('A');
13 printValue(std::string("hello"));
14 printValue(7);
15 printValue(std::string("bye"));
16 return 0;
17}

🎯 Your Answer