When adding an element to a vector, how to know that a copy of the object is going to be made?
问题 I have an object called LastQueryInfo lastQuery in my class. Every time this object changes, I add it to a vector called history . Initially, when I did history.push_back(lastQuery) I didn't know what would happen - is the vector going to make a copy of the object? or is it going to keep a reference to it? So if later I modify lastQuery, are all the objects (assuming they are references) in the history vector going to be modified? After some testing, I found that history.push_back(lastQuery)