vectors and push_back

Started by
3 comments, last by +AA_970+ 21 years, 5 months ago
Ok, lets say I have a vector vector<MyClass> myVec; When I call: myVec.push_back(Object); //assume Object is of type MyClass is Object passed by reference or is a copy of Object placed in the vector? digital radiation [edited by - +AA_970+ on November 6, 2002 3:01:58 PM] [edited by - Stoffel on November 6, 2002 4:24:19 PM]
Advertisement
It is placed in the vector
That''s why you normally should use a vector of (smart) pointers if you''re going to use it with objects.
It places a copy of the object in the vector--it''s the only exception-safe way to do it. Overload your copy constructor to output a message and you will see it called when you push_back.
thanx, exactly what i needed to know.

digital radiation

This topic is closed to new replies.

Advertisement