Did I understand correctly this C++ challenge code?
https://code.sololearn.com/cJVJFCDBroOd/?ref=app I had a hard time understanding what is going on here, but I think I have an explanation now, and i would like a confirmation that I'm reasoning correctly. vector<A> v(4,1); This uses a temporary A object for all 4 initial elements, hence the destructor is called only for that temporary. ==> 1 destructor called ==> cnt == 1 v.push_back(1); The vector needs to be resized in order to accommodate for the new element which will be inserted, so the destructor of the 4 A objects is called, as they get copied into the resized vector. Then the new element is inserted using a temporary A, whose destructor is then called. ==> 4 destructor calls for the 4 A in the vector + 1 destructor call for the temporary ==> 6 total calls Did I get it right?