Explain the types of polymorphism in C++.

: 245
Paper : C++ Programming FAQ (Frequently Asked Questions and answers) for freshers | Platform : Object-oriented programming Language | Category : Programming FAQs

There are two types of polymorphism:

  • Compile-time polymorphism: It is implemented during compile-time that's why it is known as compile-time polymorphism. It is also called static polymorphism. An example of compile-time polymorphism is Method overloading. 
    Method Overloading: It is a procedure that allows you to have more than one function with the same name but with different functionalities. 
  • Run-time polymorphism: It is implemented during run-time that's why it is known as run-time polymorphism. It is also called dynamic polymorphism. An example of run-time polymorphism is Function overriding. 
    Function Overriding: When the child class contains the same method present in the parent class. Child class overrides the method of the parent class. Both contain the same function with different functionality.