STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
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!
Students have asked these similar questions
__________can be used to assign an object of a class to another object of the same class.
Java:
We use the _____ operator to create an instance of (object in) a particular class.

Chapter 15 Solutions

STARTING OUT WITH C++ MPL

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.
Similar questions
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Systems Architecture
    Computer Science
    ISBN:9781305080195
    Author:Stephen D. Burd
    Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
C++ Data Members; Author: CppNuts;https://www.youtube.com/watch?v=StlsYRNnWaE;License: Standard YouTube License, CC-BY