Home | » | C++ Programming | » | Binding |
Binding refers to the linking of processor call to the code to be a executed in response to the call Dynamic Binding the means code associate with a given processor call is know untill the time of call and runtime. It is assocates with Polymorphism and Inheritance. There are two types of Binding.
1. Static Binding (Early Binding)
2. Dynamic Binding (Late Binding)
Static Binding (Early Binding)
Binding generally means linking. In a C++ Program choosing a function in a normal way during its compilation time is called as static binding. The static binding is also referred as Early binding or static linkage. we can say that the static binding an example of compile time binding. The below program show Static binding/early binding program.
Dynamic Binding (Late Binding)
In contrast, virtual member functions are resolved dynamically (at run-time). That is, the member function is selected dynamically (at run-time) based on the type of the object, not the type of the pointer/reference to that object. This is called binding or late binding. Dynamic binding is a result of virtual functions. If the keyword virtual is used with the function declaration in the base class, the system will use dynamic binding, which is done at run time but if the keyword is not include, static binding will be used. The below program show dynamic binding/late binding program.