I'm new to C++ and I'm stuck on the following.
Let's say we have a base class:
class A{
public:
virtual void myfunc(vector <A> *a){
// nothing to do here
}
};
And two subclasses:
class B : public A {
public:
void myfunc(vector <A> *a){
//some other code
}
};
class C : public A {
public:
void myfunc(vector <A> *a){
//some other code
}
};
Here's another class where I create misc functions:
class D {
public:
void dosomething(vector <A> * c){
// i need to call upon polymorphism here so myfunc is dynamically called for B or C
}
};
My problem lies in class D
. How can I achieve polymorphism there? I've tried a lot, but I end up still calling the base class's function.