...

/

Dynamic vs. Static Polymorphism

Dynamic vs. Static Polymorphism

Learn about polymorphism and to distinguish between dynamic and static types of polymorphism.

When we learn about object-oriented programming, we learn about its fundamental principles, which are abstraction, encapsulation, inheritance, and polymorphism. C++ is a multi-paradigm programming language that supports object-oriented programming too. Although a broader discussion on the principles of object-oriented programming is beyond the scope of this section and this course, it’s worth discussing at least some aspects related to polymorphism.

Polymorphism

So, what is polymorphism? The term is derived from the Greek words for “many forms.” In programming, it’s the ability of objects of different types to be treated as if they were of the same type. The C++ standard actually defines a polymorphic class as follows: “A class that declares or inherits a virtual function is called a polymorphic class.”

It also defines polymorphic objects based on this definition, as follows: “Some objects are ...