de inicio con su declaración de f1
:
int (*f1)(float);
¿Quieres f2
ser un puntero a una función que devuelve f1
, por lo que sustituir f1
en la declaración anterior con la declaración de f2
:
int (* f1 )(float);
|
+-----+-----+
| |
v v
int (*(*f2)(double))(float);
La declaración se lee como
f2 -- f2
*f2 -- is a pointer
(*f2)( ) -- to a function
(*f2)(double) -- taking a double parameter
*(*f2)(double) -- returning a pointer
(*(*f2)(double))( ) -- to a function
(*(*f2)(double))(float) -- taking a float parameter
int (*(*f2)(double))(float) -- returning int
se repite el proceso para f3
:
int (*(* f2 )(double))(float);
|
+---+----+
| |
v v
int (*(*(*f3)(int))(double))(float);
que dice lo
f3 -- f3
*f3 -- is a pointer
(*f3)( ) -- to a function
(*f3)(int) -- taking an int parameter
*(*f3)(int) -- returning a pointer
(*(*f3)(int))( ) -- to a function
(*(*f3)(int))(double) -- taking a double parameter
*(*(*f3)(int))(double) -- returning a pointer
(*(*(*f3)(int))(double))( ) -- to a function
(*(*(*f3)(int))(double))(float) -- taking a float parameter
int (*(*(*f3)(int))(double))(float); -- returning int
C o C++? Porque C++ tiene algunas formas más fáciles de expresar tales cosas. – Puppy
[cdecl es tu amigo] (http://cdecl.ridiculousfish.com/?q=declare+f3+as+pointer+to+function+%28int%29+returning++pointer+to+function+%28double%29+ return + puntero + a + función +% 28float% 29 + return + int) –
cdecl.org solo traduce de c-sintaxis a inglés. No es muy útil ir por el otro lado, ya que tienes que redactar tu declaración perfectamente en la forma que espera, y no es así como funciona el inglés o cualquier otro lenguaje natural. –