There is no such thing as a polymorphic vector. std::vector and any other type of container in C ++, including C type arrays always contain exactly one type. And the fact that two different containers have types that are connected does not make the types of containers connected in any way.
In your case, you probably have to build a second vector:
func( std::vector< BaseClass* >( B.begin(), B.end() ) );
Note that trying to use std::vector<DerivedClass*> as std::vector<BaseClass*> , say with reinterpret_cast , is undefined and may not work. There is no guarantee that the actual physical address of the BaseClass subobject in a DerivedClass object has the same physical address as the full object.
source share