Can you create a std::map of inherited classes?

前端 未结 4 1629
醉梦人生
醉梦人生 2021-01-14 12:14

I\'m wondering if it\'s possible to create a map of pointers of inherited classes. Here\'s an example of what I\'m trying to do:

#include 
#inc         


        
4条回答
  •  有刺的猬
    2021-01-14 12:52

    You may have template on classes and functions, but not on instances.

    You should stick to the map to BaseClass*'es.

提交回复
热议问题