There's no intrinsic support for polymorphism in C, but there are design patterns, using function pointers, base 'class' (structure) casts, etc., that can provide a logical equivalent of dynamic dispatch. Polymorphism in C++ is an important concept of object-oriented programming, which simply means many forms. It refers to the ability of a function, variable, or object to take multiple forms when the same object or entity behaves differently in different contexts. Polymorphism can occur within classes when multiple classes are related through inheritance. So, let’s dig deeper to understand what C++ polymorphism is, its types, and examples. Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance. Like we specified in the previous chapter; Inheritance lets us inherit attributes and methods from another class. Polymorphism uses those methods to perform different tasks. Typically, polymorphism occurs when there is a hierarchy of classes and they are related by inheritance. C++ polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.

Available

Product reviews

Rating 4.5 out of 5. 8,008 reviews.

Characteristics assessment

Cost-benefit

Rating 4.5 out of 10 5

Comfortable

Rating 4.3 out of 5

It's light

Rating 4.3 out of 5

Quality of materials

Rating 4.1 of 5

Easy to assemble

Assessment 4 of 5