cast list<A*> to list<B*> where B inherits A
问题 I got a function void doSomething(list<A*> list1, list<A*> list2) And classes class B : A class C : A Is there a direct way to call my function like void doSomething(list<B*> listOfB, list<C*> listOfC) or do I have to wrap it manually like void doSomething(list<B*> listOfB, list<C*> listOfC) { list<A*> l1; list<A*> l2; for (B* b : listOfB) l1.insert(b); for (C* c : listOfC) l2.insert(c); doSomething(l1, l2); //calling the function taking supertype } I tried unsuccessfully to cast list<B*> to