C++ collection of abstract base classes
问题 how can I create STL collection of classes which implement abstract base class using the base class as collection value, without using pointers? is there something in Boost that allows me to implement it? The collection specifically is map. Thanks 回答1: You cannot avoid pointers completely. You must store pointers in the collection if you want to avoid Object slicing. Boost has a container that hides the pointers pretty well: ptr_map 回答2: The Boost Pointer Container Library does what you want.