Namespaces
Variants
Views
Actions

Introduction to Polymorphism in C++

From cppreference.com


This is a work in progress, it is incomplete at this time--Draymer (talk) 08:58, 14 October 2013 (PDT)


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 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 paper 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 when compared to other programming languages.


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 take a look at polymorphism via templates.

[edit] Inheritance based Polymorphism in C++

[edit] Template based Polymorphism in C++