Cast pointer to member function to normal pointer

前端 未结 6 615
抹茶落季
抹茶落季 2020-11-28 15:52

Currently I have a class of this kind, shortened for simplicity:

class MyClass {
    public: 
        MyClass();
        void* someFunc(void* param);
}
         


        
6条回答
  •  失恋的感觉
    2020-11-28 16:49

    There is a round about way of doing it. Since C++ names are mangled you can't directly use it for non-static functions.. however since non-static functions have the same signatures as C functions, you can directly use them as callbacks. So for non-static functions, you can have static function wrappers. This page explains this approach in detail.

提交回复
热议问题