How to store various types of function pointers together?

前端 未结 4 575
滥情空心
滥情空心 2021-01-14 18:08

Normal pointers can be stored using a generic void*. e.g.

void* arr[10];
arr[0] = pChar;
arr[1] = pINt;
arr[2] = pA;

Sometime

4条回答
  •  忘掉有多难
    2021-01-14 18:47

    Use a union of your function pointer types, this works in both C and C++ and assures sufficient storage for the pointers (which are likely the same size, still...)

提交回复
热议问题