CJCoding With Joseph
15free / daySign inCreate account

Read 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
Topics
Pointers
Auto-input
12\n
This input is automatically fed to your program's stdin
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.