Question: - implement the Stack ADT using the linked list approach Attached is the StackLinked.cpp and StackLinked.h **USE C++ PROGRAMMING LANGUAGE. StackLinked.cpp #include StackLinked.h template StackLinked

- implement the Stack ADT using the linked list approach

Attached is the StackLinked.cpp and StackLinked.h **USE C++ PROGRAMMING LANGUAGE.

StackLinked.cpp

#include "StackLinked.h"

template

StackLinked::StackLinked (int maxNumber)

{

}

template

StackLinked::StackLinked(const StackLinked& other)

{

}

template

StackLinked& StackLinked::operator=(const StackLinked& other)

{

}

template

StackLinked::~StackLinked()

{

clear();

}

template

void StackLinked::push(const DataType& newDataItem) throw (logic_error)

{

}

template

DataType StackLinked::pop() throw (logic_error)

{

DataType t = 0;

return t;

}

template

void StackLinked::clear()

{

}

template

bool StackLinked::isEmpty() const

{

return false;

}

template

bool StackLinked::isFull() const

{

return false;

}

template

void StackLinked::showStructure() const

{

if( isEmpty() )

{

cout << "Empty stack" << endl;

}

else

{

cout << "Top\t";

for (StackNode* temp = top; temp != 0; temp = temp->next) {

if( temp == top ) {

cout << "[" << temp->dataItem << "]\t";

}

else {

cout << temp->dataItem << "\t";

}

}

cout << "Bottom" << endl;

}

}

------------

StackLinked.h

#ifndef STACKARRAY_H

#define STACKARRAY_H

#include

#include

using namespace std;

#include "Stack.h"

template

class StackLinked : public Stack {

public:

StackLinked(int maxNumber = Stack::MAX_STACK_SIZE);

StackLinked(const StackLinked& other);

StackLinked& operator=(const StackLinked& other);

~StackLinked();

void push(const DataType& newDataItem) throw (logic_error);

DataType pop() throw (logic_error);

void clear();

bool isEmpty() const;

bool isFull() const;

void showStructure() const;

private:

class StackNode {

public:

StackNode(const DataType& nodeData, StackNode* nextPtr)

{

dataItem = nodeData;

next = nextPtr;

}

DataType dataItem;

StackNode* next;

};

StackNode* top;

};

#endif //#ifndef STACKARRAY_H

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 Databases Questions!