栈的构建

class MyStack
{
private:
	int m_size;
	int m_top;
	char *m_pStack;
public:

MyStack::MyStack(int _size):m_size(_size),m_top(0){
	m_pStack=new char[_size];
}
MyStack::~MyStack(){
	delete []m_pStack;
	m_pStack=NULL;
}
bool MyStack::StackEmpty(){
	if(0==m_top) return true;
	return false;
}


bool MyStack::StackFull(){
	if(m_top==m_size) return true;
	return false;
}


void MyStack::clearStack(){
	m_top=0;
}
bool MyStack::pushStack(char elem){
	if(StackFull()) return false;
	m_pStack[m_top]=elem;
	m_top++;
	return true;
}
char MyStack::popStack(){
	if(StackEmpty()) return -1;
	m_top--;
	return m_pStack[m_top];
}


void MyStack::stackTraverse(){
	for(int i=0;i


你可能感兴趣的:(栈的构建)