C++ Tutorial

Define C++

C++ First Program

Difference C and C++

C++ Operators

C++ Type Casting

C++ Function Overloading

C++ Default Arguments

C++ Inline Function

C++ Define OOP's

C++ Keywords

C++ Classes

Ex: Classes

C++ Nested Classes

C++ Constructors

Ex: Constructor

C++ Friend function

C++ Operator Overloading

Ex: Operator Overloading

C++ Inheritance

C++ this pointer

C++ Polymorphism

Virtual Class & Function

C++ File Handling

Exercise: File Handling

C++ Templates

C++ Exception Handling

C++ Graphics

Exercise: Graphics

Page Stats

Visitor: 317

C++ Polymorphism

The word polymorphism is derived from two Latin words poly(many) and morphs(forms). Polymorphism means one name multiple forms. We can create different methods that have the same name but with different parameters.

Polymorphism is of two types:

  1. Compile Time Polymorphism: when the information is known to the compiler at the compile time is known as compile time polymorphism. There are two types of compile time polymorphism.
    1. Function Overloading
    2. Operator Overloading
  2. Rum Time Polymorphism: When the information is not known to the compiler at the compile time is known as run time polymorphism. An appropriate function is selected while the program is running.
    1. Virtual Function: when a function is made as virtual CPP determines which function to use at run time based on the type of object pointed by the base pointer.