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

Trace decltype With Arithmetic

mediumTemplates

📄 Code

Read carefully — what does this print?
1#include <iostream>
2 
3int main() {
4 decltype(10) a = 10;
5 decltype(10L) b = 10L;
6 decltype(10U) c = 10U;
7 decltype(5 / 2) d = 5 / 2;
8 decltype(5 / 2.0) e = 5 / 2.0;
9 std::cout << a << "\n";
10 std::cout << b << "\n";
11 std::cout << c << "\n";
12 std::cout << d << "\n";
13 std::cout << e << "\n";
14 std::cout << d + e << "\n";
15 std::cout << d * 2 << "\n";
16 return 0;
17}

🎯 Your Answer