
At Tuesday 2005-04-26 11:10, Philippe Mori wrote:
Hi, I have to classes.
class Car; class Limousine : public Car{ ... };
And two vector vector<Car> Cars; vector<Limousine> Limousines;
I want to set vector Limousines's to vector Cars( Cars = Limousines ). zlf
Since a Limousine is a Car, you should able to do
Cars.insert(Cars.end(), Limousines.begin(), Limousines.end());
at least if you have a recent compiler.
the OP should note that doing this is going to "slice" each Limousine down to a Car. IF the original intent (NOT stated) was to have a single vector which held both Cars and Limousines then some other approach would be needed (such as a vector<Car*> or better, one of the smart pointers instead of the raw Car*).
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"