I have my Base class and two derived class
class Base{
}
class Derived_1 : public Base{
}
class Derived_2 : public Base{
}
My problem is I have a vector composed of Base element which only have Derived_1/2 element and I would like to pass it in a function like this :
Void function_a( vector<Base> v){
for(auto e : v)
function_b(e);
}
void function_b(vector<Derived_1> v){}
void function_b(vector<Derived_2> v){}
Of course this code above won't work because function_b is waiting for a Derived_1/2 but I passed a Base element. Derived_1/2 class have common member that's why I made Base class.
I dont really understand about template or virtual class but I saw that we cannot instantiate it. Tried with boost::any and boost::variant but my project ask me to not add those library. Stackoverflow_question