Concept explainers
To explain how the polymorphism enables “in general” rather than specific ad also to explain its key advantages in
Explanation of Solution
Polymorphism is a Greek word where ‘poly’ means many and ‘morphism’ means forms. Thus, polymorphism is defined as the ability to acquire many forms. It can be used to develop programs which processes class objects that belong to same hierarchy of class as if all objects belong to base class in the hierarchy.
In polymorphism the base class object is set equal to the sub class objects. Thus, the base class behaves differently depending upon the functionality of sub classes.
Polymorphism helps us to ‘program in general’ and not ‘in specific’.
The advantages enabled by Polymorphism to program ‘in the general’ are given below:
- It focuses on general operations applied to all objects constructed from a class in the class hierarchy.
- It helps provide a general behavior in the code that can be used by all subclasses besides the specific code of each subclass that distinguish their functionality.
- It enables us to separate the general code from the specific code.
- It also facilitates the code extension by including new features in the class without such modification.
- The base class contains a set of member functions which all the subclasses inherit and provide their own definitions.
The advantages of programming “in general” are given below:
- It supports the re-usability of the code.
- The code can be easily extended and new functionality can be added to the existing code without such modification.
- It also helps in reducing the complexity of the code.
- It provides robustness in the program.
Want to see more full solutions like this?
Chapter 20 Solutions
C How to Program (8th Edition)
- What does operator and function overloading entail? In what ways might it be beneficial to you?arrow_forwardWith code, describe the type of polymorphism.arrow_forwardperform Early and Late Binding and explain what happen when we perform early and late binding in contest of address and what are the c++ example of early binding and late binding also explain what is the difference between function overloading and function over riding.arrow_forward
- Could you define parametric polymorphism in a subprogram and provide an example of its application?arrow_forwardwrite short definition, functions and examples are as follow: Classification rules, Association rules, Rules with exceptionsarrow_forwardCan you help me with a short and easy C++ example of class template with default argument?arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning