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

后端 未结 11 1562
臣服心动
臣服心动 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条回答
  •  清歌不尽
    2020-12-07 11:37

    I suppose the meaning is when you have two classes B,C inherits the same father class A. so, pointer of the father (type A) can hold each of sons types. The compiler cannot know what the type holds in the pointer in certain time, because it can change during the program run.

    There is special functions to determine what the type of certain object in certain time. like instanceof in java, or by if(typeid(b) == typeid(A))... in c++.

提交回复
热议问题