Watch use_count as Owners Join and Leave
mediumQuestion 707Read one integer from standard input and follow these steps in order, printing a line after each:
1. Create a, a shared_ptr<int> built with make_shared, owning that number. Print a.use_count().
2. Make b a copy of a. Print the count.
3. Make c a copy of a. Print the count.
4. Call c.reset() so c gives up ownership. Print the count.
5. Add 5 to the number through `b`, then print it through `a`.
For the input 12 the program prints exactly the output shown in Expected Output.
Do not write delete and do not use a raw new.
Expected output
after a: 1 after b: 2 after c: 3 after reset: 2 value: 17
= 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.