templateclass SeqStack{public: SeqStack(int sz):m_ntop(-1),m_nMaxSize(sz){ m_pelements=new Type[sz]; if(m_pelements==NULL){ cout<<"Application Error!"< void SeqStack ::Push(const Type item){ if(IsFull()){ cout<<"The stack is full!"< Type SeqStack ::Pop(){ if(IsEmpty()){ cout<<"There is no element!"< Type SeqStack ::GetTop() const{ if(IsEmpty()){ cout<<"There is no element!"< void SeqStack ::Print(){ cout<<"bottom"; for(int i=0;i<=m_ntop;i++){ cout<<"--->"< top"< < <
#includeusing namespace std;#include "SeqStack.h"int main(){ SeqStack stack(10); int init[10]={1,2,6,9,0,3,8,7,5,4}; for(int i=0;i<10;i++){ stack.Push(init[i]); } stack.Print(); stack.Push(88); cout< <
==============================================================================
本文转自被遗忘的博客园博客,原文链接:http://www.cnblogs.com/rollenholt/archive/2012/04/08/2438197.html,如需转载请自行联系原作者