implement the Stack ADT 50 points using the linked list app
- implement the Stack ADT (50 points) using the linked list approach
#include \"StackLinked.h\"
template <typename DataType>
 StackLinked<DataType>::StackLinked (int maxNumber)
 {
 }
template <typename DataType>
 StackLinked<DataType>::StackLinked(const StackLinked& other)
 {
 }
template <typename DataType>
 StackLinked<DataType>& StackLinked<DataType>::operator=(const StackLinked& other)
 {
 }
template <typename DataType>
 StackLinked<DataType>::~StackLinked()
 {
    clear();
 }
template <typename DataType>
 void StackLinked<DataType>::push(const DataType& newDataItem) throw (logic_error)
 {
   
 }
template <typename DataType>
 DataType StackLinked<DataType>::pop() throw (logic_error)
 {
 }
template <typename DataType>
 void StackLinked<DataType>::clear()
 {
    StackNode* t;
    while ( top != NULL)
    {
        t = top;
        top = top->next;
        delete t;
    }
 }
template <typename DataType>
 bool StackLinked<DataType>::isEmpty() const
 {
 return false;
 }
template <typename DataType>
 bool StackLinked<DataType>::isFull() const
 {
    return false;
 }
template <typename DataType>
 void StackLinked<DataType>::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;
 }
}
Class declaration for the array implementation of the Stack ADT
 //
 //--------------------------------------------------------------------
#ifndef STACKARRAY_H
 #define STACKARRAY_H
#include <stdexcept>
 #include <iostream>
using namespace std;
#include \"Stack.h\"
template <typename DataType>
 class StackLinked : public Stack<DataType> {
public:
StackLinked(int maxNumber = Stack<DataType>::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
Solution
Program to implement stack using linked list #include


