Project4-Q2 - I Got an A in this course, and I got an A+ in...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> # using namespace std; u template<class ItemType> struct NodeType { ItemType info; NodeType* next; }; } template<class ItemType> class Queue { private: NodeType<ItemType>* front; // front position NodeType<ItemType>* rear; // rear position public: Queue(); //Default class constructor //Post: Queue is created and empty. Queue(const Queue<ItemType>& anotherQueue); //Copy constructor //Implicitly called for pass-by-value void MakeEmpty(); //Post: front and rear have been reset to the empty state. bool IsEmpty( ) const; //Post: True is returned if the queue is empty. // Otherwise false is returned. bool IsFull( ) const; //Post: True is returned if the queue is full. // Otherwise false is returned. int length( ); //Post: The number of elements in the queue is returned. void Print( ); //Post: The value of all elements in the queue in the sequence // from the front to rear is printed. void Enqueue(ItemType newItem); //Pre: The queue is not full. //Post: newItem is at the rear of the queue. void Dequeue(ItemType &item); //Pre: The queue is not empty //Post: The front of the queue has been removed and a copy returned in item. ~Queue(); // Class destructor //Post: Memory for the dynamic array has been deallocated }; } template<class ItemType> Queue<ItemType>::Queue() { front = NULL; //sets front equal to NULL rear = NULL; //sets rear equal to NULL } template<class ItemType> { NodeType<ItemType>* ptr1;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2010 for the course CECS CIS 200 taught by Professor Jieshen during the Winter '08 term at University of Michigan-Dearborn.

Page1 / 5

Project4-Q2 - I Got an A in this course, and I got an A+ in...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online