Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 15, Problem 1RQE

A class that cannot be instantiated is a(n) _____ .

Expert Solution & Answer
Check Mark
Program Description Answer

The classes which cannot be instantiated are referred as “abstract base class”.

Explanation of Solution

Inheritance:

Inheritance is the concept of inheriting the members and properties of a base class from the derived class. The main advantages of inheritance are,

  • Code reusability and fast implementation.
  • Reduces the program code.

Abstract base class:

Abstract base class is a class which contains at least one pure virtual function.

  • Compiler will not permit the user to instantiate an abstract class.
  • Normally, in function the base class contains the implementation and the derived class overrides this implementation with its own implementation.
  • But, the class which inherits an abstract base class must provide definition to the pure virtual function.
    • The pure virtual functions implementation is not provided, and the function can be made pure virtual by adding (= 0) at the end of the function.
    • The pure virtual function is mostly implemented in the derived class and not in a base class.

Example for abstract base class with virtual function:

/*Abstract base class as it uses virtual function*/

class Base

{

/*Access specifier*/

public:

    /*virtual function*/

    virtual void disp() = 0

};

/*Virtual function definition*/

void Base::disp()     

{

    //statement;

}

Explanation:

In the above example,

  • Define the abstract base class with the name of “Base”.
    • Declare the pure virtual function with the name of “disp()” to make the class as the abstract class.
  • The implementation of pure virtual function “disp()” is not provided in base class. But, it is given outside of the class definition.
  • Hence, the abstract base class “Base” cannot be instantiated.

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!

Chapter 15 Solutions

Starting Out With C++: Early Objects (10th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
True or False: It is not necessary to initialize accumulator variables.

Starting Out with Java: From Control Structures through Objects (6th Edition)

List the five major hardware components of a computer system.

Starting Out With Visual Basic (8th Edition)

When the value of an item is dependent on other data, and that item is not updated when the other data is chang...

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
C++ Data Members; Author: CppNuts;https://www.youtube.com/watch?v=StlsYRNnWaE;License: Standard YouTube License, CC-BY