是的推理是有效的。将它放在不在函数参数列表中的所有'*'es的右侧,并且不在函数参数列表中的所有[]'es的左侧。然后你有
const float *(*const* name)(int)
然后像往常一样阅读。从上面,甚至如何找到正确的名称的地方,there are许多教程如何解析这个在互联网上。
对于C++,您可能需要查看geordi。
< litb> geordi: -c int name;
< geordi> Success
< litb> geordi: make name a const float *(*const*)(int) and show
< geordi> -c float const *(*const* name)(int) ;
< litb> geordi: << TYPE_DESC(const float *(*const*)(int))
< geordi> pointer to a constant pointer to a function taking an integer
and returning a pointer to a constant float
然后,您可以做分析,在它的
< litb> geordi: show parameter-declaration and first decl-specifier-seq
< geordi> `int` and `float const`.
< litb> geordi: make name an array of 2 pointer to function taking int and
returning pointer to float and show
< geordi> -c float const *(* name[2])(int);
它可以让你用英语
< litb> geordi: make name an array of 2 pointer to (float const*(int)) and show
< geordi> -c const float *(* name[2])(int);
正如你看到的混合物C的语法,这是相当强大的。
我尝试通过使用typedef将它分解成组件来避免这种令人费解的定义。 – 2010-09-21 21:31:47
c iggerish to EN:“http://cdecl.ridiculousfish.com/?q=const+float+*%28*const*+foo%29%28int%29” – Anycorn 2010-09-21 21:33:12
对于有困难的人将上面的代码插入编译器(const float *(* const *)(int));'这与'int foo(const float *(* const * var_name)(int)')是一样的。 ;' – nategoose 2010-09-21 21:36:10