Okay I have a bit of a problem which i'm struggling to solve.
Basically I have an abstract functor class that overloads operator() and derived objects that implement it.
I have a function (part of another class) that tries to take an Array of these functor classes and tries to pass a pointer to a member function to the std algorithm for_each(), here is a overview of what i'm doing:
EDIT: I have re-cleand it and put the old small example for clarity.
class A{
operator()(x param)=0;
operator()(y param)=0;
}
class B: public A{
operator()(x param); //implemented
operator()(y param);
}
...// and other derived classes from A
void ClassXYZ::function(A** aArr, size_t aSize)
{
...//some code here
for(size_t i = 0; i< aSize; i++){
A* x = aArr[i];
for(v.begin(), v.end(), ...//need to pass pointer/functor to right operator() of x here
..//other code
}
I've tried a few ways and I can't figure out how to get it to work, I need to use the abstract type as I could have different derived types but they will all have to implement the same operator()(param x) function.
I just need the for_each() function to be able to call the member function operator()(param x). I have a different function where it has concrete implementations and simply passes an instance of those and it works. I'm trying to achieve a similar effect here but without the knowledge of what concrete classes i'm given.
I don't know what i'm doing wrong but any help?