#include <iostream>
#include <stdio.h>
#include <stdint.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class FooBar{
public:
typedef void(FooBar::*OnDio)(void);
void OnDio0Irq( void ){
printf("dio0\n");
};
void OnDio1Irq( void ){
printf("dio1\n");
};
FooBar(){
OnDio dioArray[] = {&OnDio0Irq, &OnDio1Irq};
};
OnDio *dioArray[2];
private:
};
int main(int argc, char* argv[]){
typedef void(FooBar::*OnDio)(void);
void (FooBar::*foo)(void);
OnDio *myPtr;
FooBar *fb = new FooBar();
myPtr = *(&fb->dioArray[0]);
foo = (OnDio &)(myPtr[0]);
(foo)();//me need call fb->dioArray[0]()
(*myPtr)(); // ?
}
How can I call a function from an array? In my code i have error:
[Error] must use '.' or '->' to call pointer-to-member function in 'foo (...)', e.g. '(... ->* foo) (...)'
[Error] must use '.' or '->' to call pointer-to-member function in '* myPtr (...)', e.g. '(... ->* * myPtr) (...)'