Polymorphism - Kamills-12/2143-OOP GitHub Wiki
Polymorphism
Kade Miller
What Is It?
Polymorphism means "many forms,” it lets you use the same function name to do different things depending on the object calling it.
You write code that works on a base class, but when it runs, the child class decides how it behaves.
Why Use It?
- Cleaner more flexible code.
- Reuse function names across classes.
- Let different objects respond their own way without rewriting logic.
Types of Polymorphism
Compile-Time (Method Overloading)
Same function name, different parameters. The function used is decided when the code is compiled.
void log(int num);
void log(string message);