顺序栈 基本成员函数
//顺序栈 栈顶指针初始化 top==-1
//栈空:top==-1
//栈满:top==MaxSize-1
#include <iostream>
#define MaxSize 100
using namespace std;
//顺序栈 栈顶指针初始化 top==-1
//栈空:top==-1
//栈满:top==MaxSize-1
template<typename T>
class SqStackClass
{
T*data;
int top;
public:
SqStackClass();
~SqStackClass();
bool StackEmpty();
bool Push(T e);
bool Pop(T &e);
bool GetTop(T &e);
};
template<typename T>
SqStackClass<T>::SqStackClass()
{
data=new T[MaxSize];
top=-1;
}
template<typename T>
SqStackClass<T>::~SqStackClass()
{
delete []data;
}
template<typename T>
bool SqStackClass<T>::StackEmpty()
{
return (top==-1);
}
template<typename T>
bool SqStackClass<T>::Push(T e)
{
if(top==MaxSize