Page 1
Wink Notes
B.Tech CSE — 2nd Semester
Object Oriented Programming with C++
— Unit - 4 —
1. The Nature of Polymorphism
Polymorphism, derived from Greek ('poly' meaning many, 'morph' meaning form), is the ability of an interface or function to execute wildly different behaviors depending on the exact object it is interacting with.
The Conceptual Goal
Imagine an array of generic `Shape` pointers. Some point to `Circle` objects, others to `Square` objects. If you loop through them and call `ptr->draw()`, Polymorphism is the magic that ensures the correct math is executed for each shape automatically, without you writing massive `if-else` type-checking statements.
Single Interface
A universal command like 'draw()' or 'calculatePay()'.
Multiple Implementations
Every specific child class has its own unique execution logic for that command.
Dynamic Resolution
The system automatically routes the command to the correct logic at runtime.