Container of derived objects / smart pointers
问题 Lets say i have: class Base {...}; class Derived1 : public Base {...}; class Derived2 : public Base {...}; class Derived3 : public Base {...}; class Store { public: void Add(const Base&); //Adds mix of Derived1/2/3 private: vector<const Base*> vec; vector<shared_ptr<const Base> > vec_smart; }; //------------------------------------------------------ void Store::Add(const Base& b){ vec.push_back(&b); //got sliced } When using vector of pointers to Base, it got sliced. I suppose i have to use