C++的Early Binding和Late Binding

来源:互联网 发布:白俄罗斯美女知乎 编辑:程序博客网 时间:2024/06/07 03:48

C++的Early Binding:Most of the function calls the compiler encounters will be direct function calls. A direct function call is a statement that directly calls a function. 

      Late Binding:In some programs, it is not possible to know which function will be called until runtime (when the program is run). This is known aslate binding (or dynamic binding). In C++, one way to get late binding is to use function pointers. To review function pointers briefly, a function pointer is a type of pointer that points to a function instead of a variable. The function that a function pointer points to can be called by using the function call operator (()) on the pointer.

 感觉早绑定就是在函数调用过程中编译器可以直接在内存中对调用的函数进行寻址,执行被调函数

       而晚绑定则是在程序运行时才能确定子函数的地址 通常子函数的调用由函数指针来决定。

      参考 http://www.learncpp.com/cpp-tutorial/124-early-binding-and-late-binding/

原创粉丝点击