Thanks for your help, but I think I may be asking the wrong question. My CObject class has a member Actor (of type CActor) which contains a std::map<>. CPlayer is derived from CObject. CActor has a copy constructor and operator= defined like so:
CActor::CActor(const CActor &act){ Motions = act.Motions; //Motions is a std::map<>};//this is a member functionCActor& operator=(const CActor &act){ Motions = act.Motions; return(*this);}
''Motions'' is the only variable in CActor. It holds Animations referenced to std::strings, so that I can switch animations by name (ie, std::map).
Now, I have a std::vector. I fill it like this:
//''Players'' is a std::vectorPlayers.push_back();Players[0].SetWorldLocation(100 * 16, 142 * 16);Players[0].SetDrawLocation(335, 269);/*...*/
I realize its a bit of a hack (eventually I''ll read from a text file) but it does work. Almost. As soon as I try to add another player and call Players.push_back(), the Actor for Players[0] is trashed and the Motions map is empty. If I don''t call Players.push_back(), everything works fine. (Of course, I could just push_back a few before filling them, but that doesn''t seem like the best option...I want a more flexible solution.)
So, my question is, what copy semantics does a std::vector<> require a class to have? Copy construtor, operator=, or both? And how could I go about implmenting the copy functions? Magmai''s answer isn''t quite what I''m looking for, since I don''t want to deal with pointers if possible. The initialization list thing works in a simple little test project, but doesn''t seem to have fixed it on a larger scale (cedricl: now you know why I asked...) I''m thinking this has more to do with the std::vector than anything else.
Also, how can I create operator= from a copy constructor? I normally just cut&paste, but I need a better solution.