#include < iostream > using namespace std;template < class Type > class QueueItem ... {public: QueueItem(const Type&); const Type& getData(); QueueItem* getNext(); void setNext(QueueItem*);private: const Type &data; QueueItem *next;} ;template < class Type > QueueItem < Type > ::QueueItem( const Type & a):data(a) ... { next = NULL;} template < class Type > const Type & QueueItem < Type > ::getData() ... { return data;} template < class Type > QueueItem < Type >* QueueItem < Type > ::getNext() ... { return next;} template < class Type > void QueueItem < Type > ::setNext(QueueItem < Type > * a) ... { next = a;} template < class Type > class Queue ... {public: Queue(); bool isEmpty(); const Type& remove(); void add(const Type&);private: QueueItem<Type> *front; QueueItem<Type> *end;} ;template < class Type > Queue < Type > ::Queue() ... { front = NULL; end = NULL;} template < class Type > bool Queue < Type > ::isEmpty() ... { return ( front == end && front == NULL );} template < class Type > const Type & Queue < Type > ::remove() ... { const Type &temp = front->getData(); QueueItem<Type> *qu=front; front = front->getNext(); if(front == NULL) ...{ end = NULL; } delete qu; return temp;} template < class Type > void Queue < Type > ::add( const Type & data) ... { QueueItem<Type> *qu=new QueueItem<Type>(data); if( front == end && front == NULL ) ...{ front = qu; end = qu; } else ...{ end->setNext(qu); end = qu; }} int main() ... { cout<<"hehe ,you are"<<endl; Queue<int> qu; qu.add(30); qu.add(60); qu.add(90); qu.add(190); qu.add(290); qu.add(390); qu.add(30); qu.add(60); qu.add(90); qu.add(190); qu.add(290); qu.add(390); while(!qu.isEmpty()) ...{ cout<<qu.remove()<<","; } cout<<endl; return 1;}