MyLab Programming with Pearson eText -- Standalone Access Card -- for Starting Out With C++: Early Objects (My Programming Lab)
MyLab Programming with Pearson eText -- Standalone Access Card -- for Starting Out With C++: Early Objects (My Programming Lab)
9th Edition
ISBN: 9780134379548
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!
Students have asked these similar questions
C# (Odd or Even) Write an app that reads an integer, then determines and displays whether it’s odd or even. (Hints: use the remainder operator) (Multiples) Write an app that reads two integers, determines whether the first is a multiple of the second, and displays the result. (Hints: use the remainder operator). Create a class called Date that includes three pieces of information as auto-implemented properties: a month (type int), a day (type int), and a year (type int). Your class should have a constructor that initializes the three fields. Provide a method DisplayDate() that displays the three fields (separated by '/'). Write a test app named DateDemo that demonstrates class Date’s capabilities.
Time This class is going to represent a 24-hour cycle clock time. That means 0:0:0 (Hour:Minute:Second) is the beginning of a day and 23:59:59 is the end of the day. This class has these data members. int sec int min int hour
python3: Class vs Instance variable   Make a class names Foo Add a class variable to foo called x and initialize it to 5 Add an instance variable to foo called y and initialize it to 100   Make an instance of the class, call it f Using Foo., print out the value of x  (proper etiquette for class variables) Using f., Print out the value of  y (proper etiquette for instance/self. variables)   Hint: remember that class variables are the ones where their value is the same for all instances/clones.  And instance variable (which you declare inside the __init__ method with the self. preface, are unique to each clone.  When you print a class variable the proper way is to use classname . (for example Foo.x) and when you print an instance variable you use the instance handle (for example f.y.)

Chapter 15 Solutions

MyLab Programming with Pearson eText -- Standalone Access Card -- for Starting Out With C++: Early Objects (My Programming Lab)

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
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
  • 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:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
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