int main() { Stack<int> my; int a[2]; my.Push(5); my.Push(4); my.Pop(a[0]); my.GetTop(a[1]); cout<<a[0]<<a[1]<<endl; my.Destroy(); return 0; }
Exdivssion & Postfix() //将中缀表达式转变为后缀表达式 { First(); if (Get()->type == POSTFIX) return *this; Stack<char> s; s.Push('='); Exdivssion temp; ExpNode<Type> *p = Next(); while (p != NULL) { switch (p->type) { case OPND: temp.LastInsert(*p); p = Next(); break; case OPTR: while (isp(s.GetTop()) > icp(p->optr) ) { ExpNode<Type> newoptr(s.Pop()); temp.LastInsert(newoptr); } if (isp(s.GetTop()) == icp(p->optr) ) { s.Pop(); p =Next(); break; } s.Push(p->optr); p = Next(); break; default: break; } } *this = temp; pGetFirst()->data.type = POSTFIX; return *this; }