#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
/*栈*/
template <class T>
class CStack
{
public:
int m_count;
T * m_arr;
int m_curposition;
CStack(int count)
{
m_arr = new T [count];
m_count = count;
m_curposition = -1;
}
bool push(T val)
{
if(m_curposition == m_count-1)
return false;
m_arr[++m_curposition] = val;
}
T pop()
{
if(IsEmpty())
return 0;
return m_arr[m_curposition--];
}
T GetElement()
{
if(IsEmpty())
return 0;
return m_arr[m_curposition];
}
bool IsEmpty()
{
if(m_curposition < 0)
return true;
return false;
}
~CStack()
{
评论4