指向功能指针 [英] Pointer to Function Pointer
本文介绍了指向功能指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以创建指向函数指针的指针,即
Is it possible to create a pointer to a function pointer, i.e.
int32_t (*fp[2])(void) = {test_function1, test_function_2}; // initialize a function pointer
<unknown> = fp;
需要用什么代替未知?使用普通"数组,我可以做到这一点:
What needs to be written in place of unknown? With "normal" arrays, I could do this:
int a[2] = {0, 1};
int* p = a;
非常感谢.
推荐答案
typedef void(*func_ptr_t)(void); // a function pointer
func_ptr_t* ptr_to_func_ptr; // a pointer to a function pointer - easy to read
func_ptr_t arr[2]; // an array of function pointers - easy to read
void(**func_ptr_ptr)(void); // a pointer to a function pointer - hard to read
void(*func_ptr_arr [2])(void); // an array of function pointers - hard to read
这篇关于指向功能指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文