Home » Learn C++ » Early Binding and Late Binding

Early Binding and Late Binding

Early Binding:

            The events that take place at the compile time are called early binging. It is also called static binding. It indicates that all information required to call a function is known at the compile time. The compiler decides at compiler time what method will respond to the message sent to the pointer.

            The accessing of member functions of a class through the pointer is an example of early binding. In the above program example, the compiler decides at compiler time to always execute the member function of the class whose type matches the type of the pointer irrespective of the contents of the pointer. Thus whatever the object points to during execution of the program, the pointer always accesses the member of the class whose type matches with its type.

 

Late Binding:

            The events that take place at the time of execution of the program are called late binding. It is also called dynamic binding. With late binding, the complier does not known which method will actually respond of the message because the type of the pointer is not known at compiler time. If the keyword virtual is used, the system uses late binding.

            The execution of virtual function through pointers is an example of late binding. While executing a virtual function through a pointer variable, the computer decides at the time of execution of the program. It executes the function depending upon the value in the pointer during execution of the program.  

 

Other Topics

comment closed

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
Copyright © 2010 Information Village. All rights reserved.