Every time you call a method in your application, the call to the method must be associated with the method definition. Programmers refer to this as binding . Binding occurs either at compile time or at run time. Binding at compile time is called early binding and is performed if all the information needed to invoke the method is known when the application is compiled. Binding at runtime is called late binding and is performed if some information is missing at compile time that is known only when the application runs.

Early binding is used for normal method calls. No time is lost when the program runs because binding is completed when the executable program is created. This is an advantage over late binding.

Late binding is implemented using a virtual function, which is discussed in the next section. A virtual function uses a base reference to point to the type of object used by a method. In many situations, the reference to the object is not known until run time. Therefore, binding cannot occur during compile time and must wait until the program runs to bind the method call to the method.

Although late binding causes an application to run slightly slower, late binding enables a program to respond to events that occur during execution. You dont have to write code for contingencies that might occur during run time, which is an important advantage of late binding.

OOP Demystified
OOP Demystified
ISBN: 0072253630
EAN: 2147483647
Year: 2006
Pages: 130

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: