← Copy Semantics: The Copy Constructor & Copy Assignment Operator

Deep Copy Constructor

easy

Add a deep-copy copy constructor to Buffer. main creates b as a copy of a, then modifies b.data[0] – with a correct deep copy, that change should be completely invisible to a, since they now own two entirely separate arrays with (initially) equal contents.

If a.data[0] also ends up 999 in your output, the copy is shallow – both objects are still sharing one array.

Your solution

"Run" uses the sample stdin ("3"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution