Q:

C++ pass function pointer with parameter to function

I think I have misunderstood how function pointers work.  In this example:
class Helper
{
  public:

      typedef void (*SIMPLECALLBK)(const char*);
      Helper(){};
      void NotifyHelperbk(SIMPLECALLBK pCbk)
      { m_pSimpleCbk = pSbk; }
  private:
     SIMPLECALLBK m_pSimpleCbk;

}

// where i call the func
class Main
{
    public:
      Main(){};
    private:
      Helper helper
      void SessionHelper(const char* msg);

}

Main.cpp

void Main::SessionHelper(const char* msg)
{
   ....
} 

helper.NotifyHelperbk(&Main::SessionHelper);

I get the following error:
error C2664: 'Main::NotifyHelperbk' : cannot convert parameter 1 from 'void (__thiscall Main::* )(const char *)' to 'Helper::SIMPLECALLBK'
1>        There is no context in which this conversion is possible

What am I missing here?

A:

Main::SessionHelper is a non static method. So add static to it to be able to use it as function pointer. Or use member method pointer (you will need a instance to call it).

