Zeiger auf Funktion als Rückgabetyp
-
Hallo,
ich habe hier eine Funktion, die einen Zeiger auf eine andere Funktion zurück geben soll.
Mein Problem: Wie soll ich den Rückgabetyp der Funktion deklarieren???
Ich habs mal so probiert funktioniert aber nicht:double (*)(double x) GetFunction(int f_number) { static double (*functions[FUNCTIONS_COUNT])(double x) ={ f1_quad, f2_2quad, f3_2quad_plus5, }; if(f_number>=1 && f_number<=FUNCTIONS_COUNT) { return functions[f_number-1]; } else return NULL; }
-
warum das so nicht geht, weiß ich nicht. Aber mit typedef gehts:
typedef double (*fun_t)(double); fun_t GetFunction...
-
XCooperation schrieb:
double (*)(double x) GetFunction(int f_number)
double (*GetFunction(int f_number))(double)