costum grow() not working

This is a discussion on costum grow() not working within the C++ Programming forums, part of the General Programming Boards category; The following is the header file for Deque.cpp:
Code:
#ifndef DEQUE_H
#define DEQUE_H
#include <iostream>
using namespace std;
typedef int ...

So as you may guess when add() is invoked it checks to see if the Deque needs to be enlarged. If so then executes grow(), then adds the entry and counts up (which are not included in the above).
The problem is that grow() doesn't work properly. This is what it outs when the array has a size of 40:

costum Deque misbehaving

void Deque::add( const Item_type& item, bool leftEnd )
// Add an item to the rear or front of deque
// The item is added to the Deque at the rear (or front if
// the optional parameter is true)
{
if (count>=maxCount) grow();
if (leftEnd){
data[(front-1)%maxCount]=item;
--front;
}
else{
data[(count+front)%maxCount]=item;}
count++;
}
Item_type Deque::remove( bool leftEnd )
// Remove item from rear or front of queue
// An item is removed from the Deque and returned
// If the Deque is empty the return value is undefined.
// If TRUE then remove from front else from rear.
{
if (count > 0){
count--;
if (leftEnd){
front=(front+1)%maxCount;
return data[front-1];}
else{
return data[(count+front)%maxCount];}
}
}

Both are defined in Deque.cpp.
When I call B.add( A.remove() ) it works but B.add( A.remove(), TRUE) gives a Bus error -A is defined as before, with 40 items.

I have looked at many webpages about how a Deque is supposed to work (including http://gcc.gnu.org/onlinedocs/libstd...ce.html#l00866 which gives an in-depth explanation of the STL Deque) but no help. I am completely stuck at this point. My guess is that add(item, TRUE) is causing the problem. I do really appreciate any help.