Easy function pointers in C

There are several ways to declare function pointers.
Are you familiar with the following way?


#include <iostream>

typedef int MYFUNC(void);

int stub(){
return 1;
}

int x(MYFUNC & z)
{
return z();
}

int main(int argc, char* argv[])
{
MYFUNC * addr = &stub;
std::cout << x(*addr);
return 0;
}

much easier than having all those ()(* )()… isn’t it?

Leave a Reply