Difference between interface and polymorphism

c++, interface, oop, polymorphism

Solution

Polymorphism is the abstract concept of dealing with multiple types in a uniform manner, and interfaces are a way to implement that concept. Code that interacts with an interface can interact with any type that provides that interface.

Note that C++ has (at least) two forms of polymorphism: dynamic (i.e. run-time) polymorphism via interfaces formally defined by virtual functions, and static (i.e. compile-time) polymorphism via interfaces informally defined by the use of template parameters.

Problem

I was reading an online excerpt from a C++ book on polymorphism and interfaces. The book made a distinction between polymorphism and interfaces, and specified how to implement them in C++. However, I was always under the idea that interfaces in C++ (implemented using a base class with pure virtual functions) were nothing more than an application of polymorphism. I would like to know the clear distinction between polymorphism and interfaces because the excerpt confused me.

Original source

Related problems