EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
Question
Book Icon
Chapter 4, Problem 6E
Program Plan Intro

Abstract Base Class:

  • At least a single pure virtual function is present in an Abstract class. For sub classes interface is provided by Abstract class.
  • The instantiation of Abstract class is not possible whereas refrences and pointers could be created.
  • Abstract class contains a pure  virtual function  along with normal functions and variables
  • The purpose of Abstract class is to for up cast.  So that its interface could be used by derived class.
  • The implementation of all of pure virtual functions is necessary for all classes that inherit an Abstract class. Otherwise they would also become Abstract.

Blurred answer
Students have asked these similar questions
You can use inheritance or composition to design the data structures for stacks and queues. Discuss the pros and cons of these two approaches.
Consider the data structure stack's implementation. If we make an integer stack, the push and pop actions will only work with integer items. When we construct a character stack, the push and pop operations will only handle components of the character type. However, making so many copies of the implementation makes the code difficult to maintain. As a result, the genericity principle is applied, and a template class may be constructed. At runtime, this container class can handle any data type element. Explain the significance of modeling in object oriented programming using the same comparison.
Modify the C++ class for the abstract stack type shown belowto use a linked list representation and test it with the same code thatappears in this chapter. #include <iostream.h>class Stack {private: //** These members are visible only to other//** members and friends (see Section 11.6.4)int *stackPtr;int maxLen;int topSub;public: //** These members are visible to clientsStack() { //** A constructorstackPtr = new int [100];maxLen = 99;topSub = -1;}~Stack() {delete [] stackPtr;}; //** A destructorvoid push(int number) {if (topSub == maxLen)cerr << "Error in push--stack is full\n";else stackPtr[++topSub] = number;}void pop() {if (empty())cerr << "Error in pop--stack is empty\n";else topSub--;}int top() {if (empty())cerr << "Error in top--stack is empty\n";elsereturn (stackPtr[topSub]);}int empty() {return (topSub == -1);} }
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
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