Hi I was wondering if someone could explain to me a field in a struct that looks like this:
struct example {
void (SomeClass::*someMethod)();
};
What exactly is this and how/why would you use it? Thanks.
Hi I was wondering if someone could explain to me a field in a struct that looks like this:
struct example {
void (SomeClass::*someMethod)();
};
What exactly is this and how/why would you use it? Thanks.
This structure contains a pointer to a function with void return type and without parameters.
We would set this pointer to an address of actual function and execute the function via the pointer some time later. Function pointers are very convenient thing for providing different functions to handle some task depending on circumstances.
void (SomeClass::*someMethod)();
This is declaration of pointer to member function of "SomeClass" class which is accepting and returning void.