Puzzle 18 | Moving Out |
| #include <iostream> |
| #include <string> |
| |
| int main() |
| { |
| std::string hello{"Hello, World!"}; |
| std::string other(std::move(hello)); |
| std::cout << "'" << hello << "'"; |
| } |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
The program has unspecified behavior! But it probably outputs the following:
| '' |
Discussion
A moved-from object should no longer be used, as resources ...
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.