POLYMORPHISM
Static & Dynamic Binding
Polymorphism means „one name‟ -„multiple forms.
The overloaded member functions are „selected‟ for invoking by matching
arguments, both type and number. This information is known to the compiler at the
compile time and compiler is able to select the appropriate function for a particular
call at the compile time itself. This is called Early Binding or Static Binding or
Static Linking. Also known as compile time polymorphism. Early binding means
that an object is bound to its function call at the compile time.
It would be nice if the appropriate member function could be selected while the
program is running. This is known as runtime polymorphism. C++ supports a
mechanism known as virtual function to achieve run time polymorphism.
At the runtime, when it is known what class objects are under consideration, the
appropriate version of the function is invoked. Since the function is linked with a
particular class much later after the compilation, this process is termed as late
binding. It is also known as dynamic binding because the selection of the
appropriate function is done dynamically at run time.
Static & Dynamic Binding
Polymorphism means „one name‟ -„multiple forms.
The overloaded member functions are „selected‟ for invoking by matching
arguments, both type and number. This information is known to the compiler at the
compile time and compiler is able to select the appropriate function for a particular
call at the compile time itself. This is called Early Binding or Static Binding or
Static Linking. Also known as compile time polymorphism. Early binding means
that an object is bound to its function call at the compile time.
It would be nice if the appropriate member function could be selected while the
program is running. This is known as runtime polymorphism. C++ supports a
mechanism known as virtual function to achieve run time polymorphism.
At the runtime, when it is known what class objects are under consideration, the
appropriate version of the function is invoked. Since the function is linked with a
particular class much later after the compilation, this process is termed as late
binding. It is also known as dynamic binding because the selection of the
appropriate function is done dynamically at run time.