Using the next definitions
class A {};
class B : public A {};
void f(A* a) {}
calling f(new B)
is possible because B*
is implicitly converted to A*
, right?
However, when doing the same with class templates like std::vector
this generates a compile error.
void f(std::vector<A*> v)
{}
int main()
{
std::vector<B*> v;
f(v); //error! "no suitable user-defined conversion..."
return 0;
}
Why is that?