Puzzle 16 | An Overloaded Container |
| #include <initializer_list> |
| #include <iostream> |
| |
| struct Container |
| { |
| Container(int, int) |
| { |
| std::cout << "Two ints\n"; |
| } |
| Container(std::initializer_list<float>) |
| { |
| std::cout << "std::initializer_list<float>\n"; |
| } |
| }; |
| |
| int main() |
| { |
| Container container1(1, 2); |
| Container container2{1, 2}; |
| } |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
The program displays the following output:
| Two ints |
| std::initializer_list<float> ... |
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.