Category : function-pointers

As the question states, I’m trying to understand a condition that is happening in my current application. I’m attempting to load function pointers from a DLL. The DLL is loaded using LoadLibraryA and this is successful. This DLL has multiple methods that I need access to, and the typedef of those method pointers are also ..

Read more

Im interested in creating arrays of functions which don’t take arguments and don’t return anything. Is there a way to create a generic function pointer and execute it? Example: ptr ptrArray[1]; PtrArray[0] = &myfunc; More generally does this work if myfunc is a method in a specifc object? Part of me assumes not since functions ..

Read more

I have a third party class Calculation with a function setCallback: typedef void (*callback_function)(void); class Calculation { public: void setCallback(callback_function pFunc); }; and my function I want to use as callback void callback(int id); I want to create, say, four (number known at compile time) objects of Calculation and set the callback for each object. ..

Read more

I have a request for function pointer by C++. below is the sample what I need: in API file: class MyClass { public: void function1(); void function2(); void function3(); void function4(); }; in main file: MyClass globalglass; void global_function_call(???)// <—- how to do declaration of argument??? { //Do *function } int main() { global_function_call(&globalglass.function1()); // ..

Read more

I’m running into syntax errors with C++ where I have to return a pointer to a function inline. struct Note{} Observer.hpp class Observer { protected: void (*notify)(Note *note); // should this be *(*notify…)? public: void (*(*getNoteMethod)())(Note *note); }; Observer.cpp void (*Observer::getNoteMethod())(Note*) { //error: non-static data member defined out-of-line return this->notify; } I’m getting this error, ..

Read more