C++ Passing a pointer to a member function as an argument
<p>I need to pass a pointer to a member function as an argument to a member function in another class. What I'm doing is something like below.
I want to call int Processor::AddJob(void <em>(</em>_pFunc)(void*), void* _pArg) method with void* ProcessHandler::Task(void* a) as the first argument.
I did it as </p>

<pre><code>TaskFunc pFunc1 = &amp;ProcessHandler::Task;
p_Processor-&gt;AddJob(pFunc1,10);
</code></pre>

<p>But it gives the error </p>

<blockquote>
  <p>error: no matching function for call to Processor::AddJob(void*
  (ProcessHandler::<em>&amp;)(void</em>), int)’ Processor.h:47: note: candidates
  are: int Processor::AddJob(void* (<em>)(void</em>), void*)</p>
</blockquote>

<p>Can someone please help me on this.My implementation is as follows.(Not the exact code-it is much larger than this)</p>

<pre><code>class Processor 
{
public:
    Processor();
    virtual ~Processor();

    int AddJob(void *(*_pFunc)(void*), void* _pArg);
};

int Processor::AddJob(void *(*_pFunc)(void*), void* _pArg)
{
    //Job addition related code goes here
}


/////////////////////////////////////////////////////////////////////////////
typedef void* (ProcessHandler::*TaskFunc)(void*); 
class ProcessHandler
{
public:
    ProcessHandler(Processor* _pProcessor);
    virtual ~ProcessHandler();
    void* Task(void* a);
    void Init();

private:
    Processor* p_Processor;
};


void* ProcessHandler::Task(void* a)
{
    //Task related code goes here
}

void ProcessHandler::Init()
{
    TaskFunc pFunc1 = &amp;ProcessHandler::Task;
    p_Processor-&gt;AddJob(pFunc1,10); //This give the compile error.
}

/////////////////////////////////////////////////////////////////////////
int main()
{
    Processor* pProcessor = new Processor();
    ProcessHandler* pProcessHandler = new ProcessHandler(pProcessor);
    pProcessHandler-&gt;Init();
}
</code></pre>
