Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

8. Providing support during instruction.

Answered: 1 week ago