POLYMORPHISM IN C++

Maha

POLYMORPHISM

    Polymorphism means 'one name,multiple forms'. It can be broadly classified into two categories as shown 

  Polymorphism:

👉🏻Compile time polymorphism 

      * Function overloading

      * Operator overloading 

👉🏻Run time polymorphism 

      * Virtual functions

Compile-time polymorphism 

     Compile-time  polymorphism simply means that an object is bound to its function call at the compile time.

     That means, ther is no ambiguity at the compile time about which a function is to be linked to a particular function's call. This mechanism is called early binding or static binding or static linking.

     In C++, compile-time polymorphism is achieved in two ways: function overloading and operator overloading.

Need for Run-time Polymorphism

    This is where run-time polymorphism is very useful.It defers the linking of a function call to a particular class much later. at run-time.

      It is not know  which Function will be invoked till an object actually makes the function call during the program's execution. This process is refferred as late or dynamic binding..


Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send