DATA STRUCTURES AND ALGORITHM
ASSIGNMENT # 1
ADT STACK:
#include <iostream>
#include<stack> using
namespace std; template
<class ItemType> class
Stack { private: int
top; int maxStack;
ItemType* items;
public:
Stack();
Stack(int); ~Stack();
bool isEmpty(); bool
isFull(); void push(ItemType
newItem); void
pop(ItemType& item);
};
template<class ItemType>
Stack<ItemType>::Stack()
{ maxStack = 100;
top = -1;
items = new ItemType[500];
}
template<class ItemType>
Stack<ItemType>::Stack(int maxStack)
{ this->maxStack = maxStack;
top = -1;
items = new ItemType[maxStack];
}
template<class ItemType> Stack<ItemType>::~Stack()
{
delete[] items;
}
template<class ItemType> bool
Stack<ItemType>::isEmpty()
{ return (top == -1);
}
template<class ItemType> bool
Stack<ItemType>::isFull()
{ return (top == maxStack -
1);
}
template<class ItemType>
void Stack<ItemType>::push(ItemType newItem)
{ if (isFull())
{