Puzzle 14Aristotle’s Sum of Parts

 #include <iostream>
 #include <type_traits>
 
 int​ ​main​()
 {
 char​ char1 = 1;
 char​ char2 = 2;
 
 // True if the type of char1 + char2 is char
  std::cout << std::is_same_v<​decltype​(char1 + char2), ​char​>;
 }

Guess the Output

images/aside-icons/important.png

Try to guess what the output is before moving to the next page.

images/hline.png

The program displays the following output:

 0
images/hline.png

Discussion

I know, I know. This ...

Get C++ Brain Teasers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.