Puzzle 8 | Will It Move? |
| #include <iostream> |
| |
| struct Member |
| { |
| }; |
| |
| struct WillItMove |
| { |
| WillItMove() = default; |
| WillItMove(WillItMove &&) = default; |
| const Member constMember_{}; |
| }; |
| |
| int main() |
| { |
| WillItMove objectWithConstMember; |
| WillItMove moved{std::move(objectWithConstMember)}; |
| std::cout << "It moved!\n"; |
| } |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
The program displays the following output:
| It moved! |
Discussion
WillItMove has a const member. You ...
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.