C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 20, Problem 20.3E
Program Plan Intro

To explain how the polymorphism enables “in general” rather than specific ad also to explain its key advantages in programming.

Expert Solution & Answer
Check Mark

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?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
What does the term "operator and function overloading" mean? What are the advantages?
What is the definition of operator and function overloading? Is there anything beneficial about it?
Operator and function overloading—what is it? What advantages may it offer?
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning