#include <iostream>
using namespace std;
typedef void (*PF)();
void func()
{
cout << "func" << endl;
}
void caller( PF pf)
{
pf();
}
int main()
{
PF p = func;
caller(p);
system("pause");
return 0;
}
回调函数。高层调用了底层,底层反过来回调了顶层。lib用的是指针。回调函数是最终被调用的那个。
https://www.zhihu.com/question/19801131
来源2
链接:http://www.zhihu.com/question/19801131/answer/13005983
来源:知乎
你到一个商店买东西,刚好你要的东西没有货,于是你在店员那里留下了你的电话,过了几天店里有货了,店员就打了你的电话,然后你接到电话后就到店里去取了货。在这个例子里,你的电话号码就叫回调函数,你把电话留给店员就叫登记回调函数,店里后来有货了叫做触发了回调关联的事件,