Puzzle 14 | Aristotle’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 | |
---|---|
Try to guess what the output is before moving to the next page. |
The program displays the following output:
| 0 |
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.