Download these FREE Ebooks:
1. Introduction to Digital Marketing
2. Website Planning and Creation
Real-world Example: Polymorphism
Different traits might exist in the same individual at the same time. A father, a spouse, and an employee are all dual roles that a man plays.
Source: Safalta.comTherefore, the same person exhibits diverse behaviour depending on the circumstance. Polymorphism is the term for this. One of the key components of object-oriented programming is polymorphism.
Free Demo Classes
Register here for Free Demo Classes
- Compile-time Polymorphism
- Runtime Polymorphism
Compile-time polymorphismStatic polymorphism is another name for it. In order to create this form of polymorphism, either operators or functions must be overloaded.
Method Overloading: These functions are referred to as being overloaded when they have many instances of the same name but distinct arguments.
Runtime polymorphismAdditionally called Dynamic Method Dispatch. A function call to the overridden method is resolved during this procedure at runtime. Method Overriding is used to accomplish this kind of polymorphism. Contrarily, method overriding happens when a derived class defines one of the base class's member functions. It is referred to as overriding that basic function.