高手帮帮忙吗,这个函数名能这么定于吗 这么解析啊
void (*tree_get(void))(void) {void (*self)(void);
self = tree_val[tree_idx];
return self;
}
#include <stdio.h> void cc(void) { printf("cc!\n"); } void (*tree_val[])(void) = {cc}; unsigned int tree_idx = 0; void (*tree_get(void))(void) { return tree_val[tree_idx]; //注释掉这句,看编译器输出 } int main(int argc, char *argv[]) { void (*k)(void); k = tree_get(); k(); return 0; }
#include <stdio.h> int cc(int key, int val) { printf("key=%d, val =%d!\n", key, val); return key * val; } typedef void(*template)(void); void (*tree_val[])(void) = {(template)cc}; unsigned int tree_idx = 0; void (*tree_get(void))(void) { return tree_val[tree_idx]; } int main(int argc, char *argv[]) { #define REFRESH_INIT (0) #define INVALID (-1) int (*func)(int, int); func = (int(*)(int, int))tree_get(); printf("func ret = %d",func(REFRESH_INIT, INVALID)); return 0; }就是强转一下