How to pass a method as callback to another class?

后端 未结 4 585
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 01:10

I have a question regarding callbacks using tr1::function. I\'ve defined the following:

  class SomeClass {
    public:
      typedef std::tr1::function

        
4条回答
  •  醉话见心
    2021-01-26 01:56

    the function void (*)(unsigned char*, int) is a free function, which is a different type from void (SomeOtherClass::*)(unsigned char*, int), thus the error. You need an object to call the latter, while the former is a free function.

    Look at the possible solutions listed in the Boost documentation

    Another possibility is that your SomeOtherClass::myCallback is private, so you do not have access to it.

提交回复
热议问题