Static Polymorphism with Templates

http://www.quora.com/What-unique-rewards-are-awaiting-a-programmer-who-goes-through-the-hardships-of-mastering-C++/answer/Brian-Bi?srid=hqvv&share=1

How can we achieve polymorphism(runtime vtable) with templates(compile time)?

How can one achieve static(compile time) polymorphism(runtime)?
Last edited on
There are multiple types of polymorphism. Polymorphism just means you have the same interface for different data types.

Templates: parametric polymorphism
Inheritance: subtype polymorphism (this is what we usually mean when talking about polymorphism)
Function overloading: ad hoc polymorphism

https://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29#Types_of_polymorphism
Last edited on
I can't believe templates and function overloading are polymorphism types. But static subtype polymorphism is where things starts getting interesting.

https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern

Thanks @Peter87
Topic archived. No new replies allowed.