In my application I use a method of a C++ - API that is defined like this:
ApiDataType_::specialApiMethod(ApiInterface *pVar, void* pV)
So as first parameter I need a parameter of typeApiInterface
.
If I declare a static method testFunc()
in my program, I can use this method as first parameter in specialApiMethod()
.
//.h
public:
static void testFunc(ApiDataType adt, void* ptr);
//.cpp
{
myClassObj->specialApiMethod(MyClass::testFunc, this)
}
This only works if testFunc()
is static. Without the static keyword, it will not work. Why this works with the static keyword?