3、ssert.h>#include#includeconstintstackIncreament=0;classopst{public:opst(intsz=50){maxSize=sz;top=-1;elements=newchar[maxSize];assert(elements!=NULL);}~opst(){delete[]elements;}boolIsEmpty(){return(top==-1)?true:false;}boolIsFull(){return(
4、top==maxSize-1)?true:false;}voidPush(char&x);boolPop(char&x);boolgetTop(char&x);intgetSize()const{returntop+1;}voidMakeEmpty(){top=-1;}voidinput();voidConvert();friendostream&operator<<(ostream&os,opst&s);private:char*elements;inttop;intmaxSize;voidoverflo
5、wProcess();};voidopst::overflowProcess()//溢出处理{char*newArray=newchar[maxSize+stackIncreament];for(inti=0;i<=top;i++)newArray[i]=elements[i];maxSize=maxSize+stackIncreament;delete[]elements;elements=newArray;}voidopst::Push(char&x){3if(IsFull()==true)overfl
6、owProcess();elements[++top]=x;}boolopst::Pop(char&x){if(IsEmpty()==true)returnfalse;x=elements[top--];returntrue;}boolopst::getTop(char&x){if(IsEmpty()==true)returnfalse;x=elements[top];returntrue;}ostream&operator<<(ostream&os,opst&s){os<<"top=="<7、endl;for(inti=0;i<=s.top;i++)os<