What is binding / Early Binding / Late Binding



What is binding / Early Binding / Late Binding

What is binding?

Binding for functions means that wherever there is a function call, the compiler needs to know which function definition should it be matched to. This depends upon the signature of each function declaration & the assignments that are taken. Also, the compiler needs to know that when this matching between the function call and choosing the correct definition will happen.

Early Binding

Early binding is a phenomenon wherein the decision to match various function calls happens at the
compile time itself and the compiler directly associates the link with addresses. It is also known as
Static Binding or Compile-time Binding.

• As we know we write code in the high-level language
Then the compiler converts this into low-level language that computer can understand, mostly machine language at the time of compilation
• In early binding, the compiler directly provides the address of function declaration instruction to the function call instruction
• Thus as the name suggests the binding happens very early before the program runs.

Late Binding

In late binding, the compiler identifies the object at runtime and then matches the function call with
the correct function. It is also known as Dynamic Binding or Runtime Binding. By default, early
binding takes place and This can be achieved by declaring a virtual function.

Post a Comment

0 Comments