简体   繁体   English

函数返回指向函数指针的指针

[英]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. 如果答案是肯定的,请告诉我如何请。

Of course you can. 当然可以。 The easiest and most readible way is to have an intermediate typedef , something like this: 最简单,最易读的方法是使用中间typedef ,如下所示:

typedef int* (*pFunc)(void);

and then it's simply: 然后简单地说:

typedef pFunc (*pFuncRetFunc)(void);
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 . 这将FP定义为一种类型,它表示函数指向函数的函数,该函数返回一个返回指向int的函数的函数指针。 All function (types) involved take no arguments. 涉及的所有函数(类型)都不带参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM