Thanks to those guys who helped me out yesterday. I have one more problem; my print function for the queue program doesnt work and goes into an endless loop. Also I am unable to calculate the length of my queue. I started getting compilation errors when I included a length
function.

template<class ItemType> 
void Queue<ItemType>::MakeEmpty() 
{ 
     rear = maxQue - 1; 
     front = maxQue - 1; 

} 


template<class ItemType> 
bool Queue<ItemType>::IsEmpty() 
{ 
     return (rear==front); 

} 


template<class ItemType> 
bool Queue<ItemType>::IsFull() 
{ 
     return ((rear+1) % maxQue == front); 

} 


template<class ItemType> 
int Queue<ItemType>::length() 
{ 
    return 0; // I dont know what to put here 

} 


template<class ItemType> 
void Queue<ItemType>::Print() 
{ 
   int current; 
   current = rear; 
   do{ 
         current = (current + 1) % maxQue; 
         std::cout << items[current] << std::endl; 
       }while(current != front); 

} 


// Main function items 

    IntQueue.Enqueue(1); 
    IntQueue.Enqueue(2); 
    IntQueue.Enqueue(3); 
    IntQueue.Enqueue(4); 
    cout << "int length 3 = " << IntQueue.length() << endl; 
    IntQueue.Dequeue(x); 
    cout << "int length 4 = " << IntQueue.length() << endl; 
    IntQueue.Print();

my length function has no code and I dont know what to put in there.

Nice try on the code tags, try using the preview button first before submitting them (it's

, not <code>).

[code=cplusplus]
   int current; 
   current = rear; 
   do{ 
         current = (current + 1) % maxQue; 
         std::cout << items[current] << std::endl; 
   }while(current != front);

First you tell the compiler to start at the end of the list. Then you tell it to keep looping forward until it reaches the front of the list. ????

You're printing everything except the items in the list. length() ? Hint: subtraction and abs .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.