Introduction to Polymorphism in C++
The generic definition of the word polymorphism is the occurrence of something in several different forms. When considered relative to computer science, software engineering, and all things related to developing a software system, it is often said that polymorphism is lacks a clear explanation. Nothing could be further from the truth.
In 1985, Luca Cardelli and Peter Wegner released their seminal paper On Understanding Types, Data Abstraction and Polymorphism. The work built on work previously done by Liskov and Strachey, to provide a clear definition of polymorphism in modern software systems. C++ provides some of the richest support for the varied types of polymorphism as well the concepts of type and class.
In this section, you will gain an understanding of polymorphism, including theory and practice, as it applies to C++. To prevent this from becoming a tome, I will delegate several issues to the C++ FAQs. There are two mechanisms in C++ that are used for the purpose of polymorphism. The first one is inheritance based, and the second one makes use of the C++ mechanism for parameterized types, templates. We'll start with inheritance based polymorphism, and then talk about polymorphism via templates.