What you mean by early binding and late binding? How it is related to dynamic binding?


[This c++ interview question is related to question about virtual functions ]

Binding is the process of linking actual address of functions or identifiers to their reference. This happens mainly two times.

  • During compilation : This is called early binding

For all the direct function references compiler will replace the reference with actual address of the method.

  • At runtime : This is called late binding.

In case of virtual function calls using a Base reference, as in shown in the example of question no: 2, compiler does not know which method will get called at run time. In this case compiler will replace the reference with code to get the address of function at runtime.

Dynamic binding is another name for late binding.


© 2017