如何读取函数指针?

UnS*_*Sat 2 c++

如何解释以下 C++ 声明?

int (*(*x[2])())[3]; 
Run Code Online (Sandbox Code Playgroud)

这是来自Type-cppreference中的示例。

Ram*_*eno 5

问题中示例声明的解释位于链接的Type-cppreference页面中。

int (*(*x[2])())[3];      // declaration of an array of 2 pointers to functions
                          // returning pointer to array of 3 int
Run Code Online (Sandbox Code Playgroud)

因此,真正的问题并不是特别针对该案例;而是针对该案例。但关于如何读取任何 C++ 声明。

您可以从声明的名称开始x并根据括号顺时针移动来推断所有这些详细信息。您将看到上面的描述:

x 是一个 2 维指针数组,这些函数返回一个指向 3 维整数数组的指针。

这里更好地解释为顺时针/螺旋规则http://c-faq.com/decl/spiral.anderson.html