Dynamic polymorphism is obtained through the use of abstract base classes, base class pointers and virtual function calls. Designers cast their application architecture in terms of abstract classes and the interfaces they provide and then substitute derived class object addresses where base class object addresses are expected. Virtual function calls are resolved with the aid of a virtual function table.
Static polymorphism is obtained by creating function or class templates.
If a class can be thought of as a mold for an object, a class template can be thought of as being a mold for a class, which is then used to create an object. Creating and using class and function templates is a good way to write reusable source code - as long as it's done right. In this article I will show you how to declare and implement a template class and its methods. I'll use a fairly extensive example so you can get a feel for the power designing with template classes and static polymorphism has to offer. If you've ever implemented a data structure of some kind, such as an array or binary tree, you probably tailored it to the problem at hand.