zoukankan      html  css  js  c++  java
  • 动态绑定与动态分发-动态绑定暗含动态分发

    绑定:建立联系;

    分发:作出选择。

    https://en.wikipedia.org/wiki/Dynamic_dispatch

    https://en.wikipedia.org/wiki/Late_binding

    Dynamic dispatch is different from late binding (also known as dynamic binding). In the context of selecting an operation, binding refers to the process of associating a name with an operation. Dispatching refers to choosing an implementation for the operation after you have decided which operation a name refers to. With dynamic dispatch, the name may be bound to a polymorphic operation at compile time, but the implementation not be chosen until runtime (this is how dynamic dispatch works in C++). However, late binding does imply dynamic dispatching since you cannot choose which implementation of a polymorphic operation to select until you have selected the operation that the name refers to.

    Binding refers to the process of associating a name with an operation.

    the main thing here is function parameters these decides which function to call at runtime 

    Dispatching refers to choosing an implementation for the operation after you have decided which operation a name refers to.

    dispatch control to that according to parameter match

    http://en.wikipedia.org/wiki/Dynamic_dispatch

    hope this help you

    In C++, both are same.

    In C++, there are two kinds of binding:

    • static binding — which is done at compile-time.
    • dynamic binding — which is done at runtime.

    Dynamic binding, since it is done at runtime, is also referred to as late binding and static binding is sometime referred to as early binding.

    Using dynamic-binding, C++ supports runtime-polymorphism through virtual functions (or function pointers), and using static-binding, all other functions calls are resolved.

    The link itself explained the difference:

    Dynamic dispatch is different from late binding (also known as dynamic binding). In the context of selecting an operation, binding refers to the process of associating a name with an operation. Dispatching refers to choosing an implementation for the operation after you have decided which operation a name refers to. 

    and

    With dynamic dispatch, the name may be bound to a polymorphic operation at compile time, but the implementation not be chosen until runtime (this is how dynamic dispatch works in C++). However, late binding does imply dynamic dispatching since you cannot choose which implementation of a polymorphic operation to select until you have selected the operation that the name refers to.

    But they're mostly equal in C++ you can do a dynamic dispatch by virtual functions and vtables.

    C++ uses early binding and offers both dynamic and static dispatch. The default form of dispatch is static. To get dynamic dispatch you must declare a method as virtual.

  • 相关阅读:
    Android webView 缓存 Cache + HTML5离线功能 解决
    android 退出系统
    WebView简介(加速加载篇)
    android 处理Back键按下事件
    android 极细线
    [cnblog新闻]历史性时刻:云硬件支出首次高于传统硬件
    Oracle ORDS的简单SQL配置模板
    [cnbeta]华为值多少钱,全世界非上市公司中估值最高的巨头
    其他数据库的restful方式
    [CB]2018全球半导体营收4700亿美元 三星继续碾压英特尔
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8306248.html
Copyright © 2011-2022 走看看