简体   繁体   English

函数指针返回多维数组的函数

[英]Function pointer to function returning Multidimensional array

With respect to this question, we can declare a function that returns pointer to array as: 关于这个问题,我们可以声明一个返回指向数组的指针的函数:

int (*function())[3]

which returns Ax3 array, ok. 返回Ax3数组,好的。

How is the proper way to declare a function pointer that points this kind of function? 如何声明指向这种函数的函数指针的正确方法是什么?

        f                 -- f
       *f                 -- is a pointer
      (*f)()              -- to a function
     *(*f)()              -- that returns a pointer
    (*(*f)())[3]          -- to a 3-element array 
int (*(*f)())[3]          -- of int

See this reference , which is quite helpful. 请参阅此参考 ,这非常有用。 Note the techniques using typedefs 请注意使用typedef的技术

typedef int (*pfintarray())[3];

pfintarray myFunc() { /* etc

Perhaps 也许

int (*(*function_pointer)())[3];

(at least gcc seems to understand it) (至少gcc似乎明白了)

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

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