I have a Base class and a Sub class:
class Base{
public:
Base(){}
// ...
};
class Sub: public Base{
int param;
public:
Sub(){}
// ...
};
And also I have a function that requires a vector of Base like this:
void doSomeThing(vector<Base> vectorOfBases){
// ...
}
I need to call the function like this:
vector<Sub> myVectorOfSubs;
doSomeThing(myVectorOfSubs);
The compiler tell me that:
there is no appropriate conversion from vector< Sub > to vector< Base >
So how can I pass a vector of Sub class to a function that requires a vector of Base class?