How to declare a pointer to a function?
int * ptrInteger; /We have put a * operator between int
and ptrInteger to create a pointer./
int * foo(int); //This is wrong
Bcoz..C operator precedence also plays role here ..so in this case, operator () will take priority over operator *. And the above declaration will mean – a function foo with one argument of int type and return value of int * i.e. integer pointer.
we have to bind operator * with foo somehow. And for this, we would change the default precedence of C operators using () operator.
int (*foo)(int); //Correct
Written by ranjeet kumar
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Tips
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#