Hi ,
i know how to write a syntax for function returning a integer pointer --> int *fun(int,int)
can any one suggest to how to write a syntax for function returning a integer pointer to a function taking arguments as two integer valules.
Hi ,
i know how to write a syntax for function returning a integer pointer --> int *fun(int,int)
can any one suggest to how to write a syntax for function returning a integer pointer to a function taking arguments as two integer valules.
Create a typedef for the function pointer, then it all becomes dead easy
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
The nice way to do it is to write out the function pointer type in a typedef, like
typedef int (*foo)(void);
Just like defining a function pointer, but foo is a name, so you can return a foo type.
Thanks laserlight and whiteflags.
Whiteflags, u mean
int *fun(void) ---> function returns integer pointer?
int (*foo)(void) --> function returning a integer pointer to a function taking no arguments?
am i right?
typedef int (*foo)(void);
foo function(int, foo);
foo bar;
bar = function(42, somefunction);
foo is a pointer to a function that returns an int and takes no arguments. bar is a variable of type foo. function is a function that takes an int argument and a foo argument, and returns a foo type.
Then I gave you a line of code calling the function named function.
Code:Try this one, typedef int (*foo)(void); /* here, foo is a pointer to a function which taking no arguments and returning integer. */ foo fun(); /* here, fun is function which takes no arguments and returing foo(pointer to a function which taking no arguments and returning integer) */