What is the difference between dynamic dispatch and late binding in C++?

后端 未结 11 1539
臣服心动
臣服心动 2020-12-07 10:52

I\'ve recently read about the Dynamic Dispatch on Wikipedia and couldn\'t understand the difference between dynamic dispatch and late binding in C++.

When each one

11条回答
  •  萌比男神i
    2020-12-07 11:30

    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.

提交回复
热议问题