急死了。。。。大神告诉我为什么程序会崩溃掉
/******************************************************************
#include<iostream>
#include"Mystack.h"
using namespace std;
Mystack::Mystack(int size)
{
m_iSize=size;
m_iTop=0;
char *m_pBuffer=new char[m_iSize];
}
Mystack::~Mystack()
{
delete[]m_pBuffer;
m_pBuffer=NULL;
}
bool Mystack::stackFull()
{
if(m_iTop==m_iSize)
{
return true;
}
return false;
}
bool Mystack::stackEmpty()
{
if(0==m_iTop)
{
return true;
}
return false;
}
int Mystack::stackLength()
{
return m_iTop;
}
void Mystack::clearStack()
{
m_iTop=0;
}
bool Mystack::Push(char element)
{
if(stackFull())
{
cout<<"栈已满"<<endl;
return false;
}
m_pBuffer[m_iTop]=element;
m_iTop++;
return true;
}
bool Mystack::Pop()
{
if(stackEmpty())
{
cout<<"栈已空"<<endl;
return false;
}
m_iTop--;
return true;
}
void Mystack::stackTravelse()
{
for(int i=0;i<m_iTop;i++)
{
cout<<m_pBuffer[i]<<" ";
}
cout<<endl;
}
**************************************************************/
/*************************************************************
#ifndef MYSTACK_H_
#define MYSTACK_H_
class Mystack
{
public:
Mystack(int size);
~Mystack();
bool stackFull();
bool stackEmpty();
int stackLength();
void clearStack();
bool Push(char element);
bool Pop();
void stackTravelse();
public:
char *m_pBuffer;
int m_iSize;
int m_iTop;
};
#endif
***************************************************************/
/**************************************************************
#include<iostream>
#include"Mystack.h"
using namespace std;
int main()
{
Mystack *pmystack=new Mystack(4);
delete pmystack;
pmystack=NULL;
return 0;
}
**********************************************/