Hand Off Ownership with std::move
mediumQuestion 705Read one integer from standard input. Create a unique_ptr<int> named first that owns a heap int holding that number and print its value. Then move ownership into a second unique_ptr<int> named second using std::move, and print the value through second followed by whether each pointer is now null.
For the input 9 the program prints exactly the output shown in Expected Output.
The last two lines print the result of a comparison (1 for true, 0 for false), never a pointer itself. Do not write delete and do not use a raw new.
Expected output
first holds: 9 after move second holds: 9 first is null: 1 second is null: 0
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.