user3614789
user3614789

Reputation: 200

Function returning pointer to function pointer

can you define function pointer return integer pointer? answer is yes. and it should be like this---->

integer*(*function)();

and my question is , can you define function pointer return function pointer? if answer is no! teach me please. if answer is yes, tell me how please.

Upvotes: 2

Views: 157

Answers (2)

alk
alk

Reputation: 70893

typedef int * (* (* FP)(void))(void);

This defines FP to be a type that represents a function pointer to a function returning a function pointer to a function returning a pointer to int. All function (types) involved take no arguments.

Upvotes: 1

Paul Evans
Paul Evans

Reputation: 27567

Of course you can. The easiest and most readible way is to have an intermediate typedef, something like this:

typedef int* (*pFunc)(void);

and then it's simply:

typedef pFunc (*pFuncRetFunc)(void);

Upvotes: 7

Related Questions