C++ Functions
1 How do I declare, assign and call a pointer to a function?
int f(int, char)
{
// ...
}
// ...
int (*pf)(int, char); // pointer to a function
pf = f; // assignment
pf = &f; // alternative
int r = (*pf)(42, 'a');
2 How do I declare a type of a pointer to a function?
typedef int (*pf)(int, char);
3 How do I declare an array of pointers to a function?
typedef int (*pf)(int, char);
pf pfarray[10]; // array of 10 pointers to a function
0 comments:
Post a Comment