How to implement function with vector of derived classes as parameter
问题 (Related to a previous unanswered question I asked). I want to implement a function which can be called only with vectors of related classes as parameter. For eq if we have class A; class B: public A; class C: public A; class D then it should be possible to call function with vector<A*>,vector<B*> or vector <C*> but not vector <D*> Any suggestions 回答1: I guess you already tried to create a method like void doSomething(std::vector<A*>& things) { } and tried do pass std::vector<B*> bList = ...;