C++的Early Binding和Late Binding

xiaoxiao2021-02-28  108

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/

转载请注明原文地址: https://www.6miu.com/read-63403.html

最新回复(0)