[flydream@flydream ThinkingInC++]$ cat PointerFunction.cpp
#include <iostream>
using namespace std;
void F(int a)
{
cout << "a = " << a << endl;
}
int main(int argc, char **argv)
{
void (* PF)(int); /* 定义一个函数指针 */
PF = F; // 初始化
void (* xx)(int) = F; /* 定义一个函数指针并且初始化 */
(*PF)(5);
(*xx)(90);
return 0;
}
[flydream@flydream ThinkingInC++]$ g++ PointerFunction.cpp
[flydream@flydream ThinkingInC++]$ ./a.out
a = 5
a = 90
[flydream@flydream ThinkingInC++]$