Question: In project 6 , you defined an ADT FrontList, which restricts insertions, removals, and retrievals to the first item in the list. A class definition

In project 6, you defined an ADT FrontList, which restricts insertions, removals, and retrievals to the first item in the list. A class definition for the ADT FrontList is provided below:
template
class FrontList
{
public:
// Sees whether this list is empty.
virtual bool isEmpty() const =0;
// Gets the current number of entries in this list.
virtual int getLength() const =0;
// Inserts an entry into the front of this list
virtual bool insert(const ItemType& newEntry)=0;
// Removes the entry at front of this list.
virtual bool remove()=0;
// Removes all entries from this list.
virtual void clear()=0;
// Gets the entry at the front of this list.
virtual ItemType getEntry() const =0;
// Replaces the entry at front of this list.
virtual void setEntry(ItemType& newEntry)=0;
private:
//data members here
......
};
Question 5(10 points)
Define the ADT stack as a derived class from the ADT FrontList using private inheritance (AsA relationship). Which of the following answers is the correct class definition?
Question 5 options:
a)
template
class StackAsA : private FrontList
{
Public:
StackAsA ();
StackAsA (const StackAsA & aStack);
virtual ~ StackAsA ();
bool isEmpty() const;
bool push(const ItemType& newItem);
bool pop();
ItemType peek() const throw(PrecondViolatedExcep);
};
b)
template
class StackAsA
{
private:
FrontList fList;
Public:
StackAsA ();
StackAsA (const StackAsA & aStack);
virtual ~ StackAsA ();
bool isEmpty() const;
bool push(const ItemType& newItem);
bool pop();
ItemType peek() const throw(PrecondViolatedExcep);
};
c)
template
class StackAsA : private FrontList
{
Private:
Node* topPtr;
Public:
StackAsA ();
StackAsA (const StackAsA & aStack);
virtual ~StackAsA();
bool isEmpty() const;
bool push(const ItemType& newItem);
bool pop();
ItemType peek() const throw(PrecondViolatedExcep);
};
d)
template
class StackAsA: private FrontList
{
private:
FrontList fList;
Public:
StackAsA ();
StackAsA (const StackAsA & aStack);
virtual ~ StackAsA ();
bool isEmpty() const;
bool push(const ItemType& newItem);
bool pop();
ItemType peek() const throw(PrecondViolatedExcep);
};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!