本文共 1055 字,大约阅读时间需要 3 分钟。
templateclass SeqQueue{public: SeqQueue(int sz):m_nrear(0),m_nfront(0),m_ncount(0),m_nMaxSize(sz){ m_pelements=new Type[sz]; if(m_pelements==NULL){ cout<<"Application Error!"< void SeqQueue ::MakeEmpty(){ this->m_ncount=0; this->m_nfront=0; this->m_nrear=0;}template bool SeqQueue ::IsEmpty(){ return m_ncount==0;}template bool SeqQueue ::IsFull(){ return m_ncount==m_nMaxSize;}template bool SeqQueue ::Append(const Type item){ if(IsFull()){ cout<<"The queue is full!"< Type SeqQueue ::Delete(){ if(IsEmpty()){ cout<<"There is no element!"< Type SeqQueue ::Get(){ if(IsEmpty()){ cout<<"There is no element!"< void SeqQueue ::Print(){ cout<<"front"; for(int i=0;i "< rear"< < <
#includeusing namespace std;#include "SeqQueue.h"int main(){ SeqQueue queue(10); int init[10]={1,6,9,0,2,5,8,3,7,4}; for(int i=0;i<5;i++){ queue.Append(init[i]); } queue.Print(); cout< <
转载地址:http://qlmpa.baihongyu.com/