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

decltype(x) Versus decltype((x))

mediumTemplates

📄 Code

Read carefully — what does this print?
1#include <iostream>
2 
3int main() {
4 int x = 5;
5 decltype(x) a = x;
6 decltype((x)) b = x;
7 std::cout << x << " " << a << " " << b << "\n";
8 a = 50;
9 std::cout << x << " " << a << " " << b << "\n";
10 b = 7;
11 std::cout << x << " " << a << " " << b << "\n";
12 return 0;
13}

🎯 Your Answer