I have a functor defined within a class. I want to access member function of the outer class directly from the functor. How do I do that? I want to pass this functor to a template class elsewhere in the code. I dont want to use function pointers.
Does the functor need to keep a reference to the internal class as a member, assigned to it at the time of initilization, to be able to call that class's function?
Class MyClass //outer class
{
void DoSomething() //member function I want to access from functor
{
}
class MyFunctor //the functor who wants to access outerclass's function
{
void operator() ()
{
DoSomething() //This is a member function of outer class
}
}
};
}
say if I want to keep a local reference to the outer class inside the functor then how do I create an instance (not a pointer) to the functor and pass the pointer to the outerclass in functor's constructor?