• 动态绑定与动态分发-动态绑定暗含动态分发


    绑定:建立联系;

    分发:作出选择。

    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.

  • 相关阅读:
    英语翻译预测
    mybatis 实现增删改查
    jsp项目 在maven中使用,web.xml pome.xml 的配置
    来整理一份我觉得比较重要的小概念
    前端开发项目资源网站
    css 选择器符号
    css实现三栏布局的几种方法及优缺点
    MVC设计思想
    WebSocket 与 Polling , Long-Polling , Streaming 的比较!
    移动端视频h5表现问题汇总
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8306248.html
Copyright © 2020-2023  润新知