Meandering Through the Maze of MFC Message and Command Routing Paul DiLascia Paul DiLascia is a freelance software consultant specializing in developing C++ applications for Windows. He is the author of Windows++: Writing Reusable Code in C++ (Addiso
什么是回调?通常发生在需要两个角色即调用者与实现者的情形上,即我们希望当产生某个事件时,调用实现者定义的某个函数.当然这个概念很大,不是说操作系统的信号量,条件变量什么的,是在语言级别实现,如一个Framework提供商,规定了整个程序的框架,可能产生某事件时它希望调用某个行为,而这个行为的具体定义是由framework客户来完成. 我们从简单的做起,通过一个个为什么最终来获得一个比较好的回调实现. C语言中用全局函数实现回调最简单了: void callback(int a) { co