What is the difference between subtype, parametric, and ad-hoc polymorphism?
Last updated
Subtype (inclusion) polymorphism: a supertype reference calls the right subtype behavior at runtime via inheritance and overriding (e.g.
Shape.area()on aCircle).Parametric polymorphism: one implementation works uniformly over any type through generics or templates (e.g.
List<T>).Ad-hoc polymorphism: one name with separate type-specific implementations chosen at compile time (method or operator overloading).
- https://www.geeksforgeeks.org/dsa/ad-hoc-inclusion-parametric-coercion-polymorphisms/
- https://www.tutorialspoint.com/article/types-of-polymorphisms-ad-hoc-inclusion-parametric-and-coercion
- https://dev.to/m__mdy__m/polymorphism-in-javascript-3l84
- https://medium.com/@adarsh_tech/polymorphism-types-in-oops-5382c05c8d46
- https://en.wikipedia.org/wiki/Polymorphism_(computer_science)