是的推理是有效的。將它放在不在函數參數列表中的所有'*'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