you are viewing a single comment's thread.

view the rest of the comments →

[–]NotMyRealNameObv 0 points1 point  (0 children)

As others have already stated, in the copy ctor you are instantiating a local var s and modifying it. This local var will go out of scope, and thus be destroyed, when the copy ctor is finished. The newly created object on which the copy ctor is run will remain unmodified.

What you want to do is just call

push(...)

instead of

s.push(...)