I have a question on how to store methods from multiply other class in an array.
All this code is for an arduino controller. The AP_ATO class is instanced as myATO in its .cpp file.
In the .h file,
1 2 3 4 5 6 7 8
#include <AP_ATO.h>
typedefvoid (*inputHandler)();
class AP_expandedInput{
...
inputHandler callback[8];
...
The type of "inputHandler" cannot take the address of a member-function. Instead, you must specify the class to which the function belongs during "inputHandler's"" declaration, like so:
typedefvoid( SomeClass:: *InputHander )( );
And then when creating a pointer, you must specify a function's address:
InputHandler NewHandler( &SomeClass::Function );
Calling a member-function through a function-pointer is a little strange:
Yes. A pointer to a member-function can only reference instances of the class to which its bound to. In my above examples, "NewHandler" can only call the "SomeClass::Function" function of all instances of "SomeClass", unless you redirect the pointer to another member-function of the same class that matches the specification set by the function-pointer.