- 定义函数指针类型
typedef unsigned int UINT32;
typedef UINT32 (*PFUNC)(UINT32) ;
2.定义同类型多个函数
UINT32 procOf1(UINT32 uwData)
{
// do something 1
return 0;
}
UINT32 procOf2(UINT32 uwData)
{
// do something 2
return 0
}
- 定义函数指针数组
PFUNC afunc[] = {procOf1, procOf2};
- 使用时 * 解析
int tot = 2;
for(int i = 0; i < tot; ++i)
{
UINT32 currentData = rand();
cout << (*afunc[i])(currentData);
}