《C++程序设计》(Bjarne Stroustrup)书摘
函数指针是什么
函数的地址
如何声明函数指针
假设函数为
void error(string s) { printf(s) }
相应函数指针为
void (*efct)(string s)
使用函数指针
让指针指向函数
efct = &error
用函数指针调用函数
(*efct)(string s)
把函数指针作为一种类型
定义类型
typedef void (*Name)(string s)
使用该类型
比如定义一个函数指针的数组,分别指向几个函数
Name func[] = {&A, &B}