February 2005
Beginner to intermediate
272 pages
4h 53m
English
The main confusion with pointer to function and pointer to array declarations arises because the function and array modifiers have higher precedence than the pointer modifier, so parentheses are often required.
int *f1(); // function that returns int *int (*fp1)(); // ptr to function that returns int
The same problem obtains with the high-precedence array modifier:
const int N = 12;int *a1[N]; // array of N int *int (*ap1)[N]; // ptr to array of N ints
Of course, once one can have a pointer to a function or to an array, one can have a pointer to such a pointer:
int (**ap2)[N]; // ptr to ptr to array of N intsint *(*ap3)[N]; // ptr to array of N int *int (**const fp2)() = 0; // const ptr to ...
Read now
Unlock full access