Page Stats
Visitor: 466
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:
- 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.
- Function Overloading
- Operator Overloading
- 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.
- 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.