I have been struggling with the for two evenings, and can't seem to get anything other than garbage out. I know it is probably becasue of garbage in but I can't figure how to eliminate that.
This is what I have for the copy constructor:
I am now getting the count correct for the "copy to" queue but that is because I made an explicit assignment. The elements in the "copy to" queue have garbage values.
void queueType<Type>::copyQueue(const queueType<Type>& otherQueue)
if (queueFront != NULL)
if (otherQueue.queueFront == NULL)
queueFront = 0;
queueRear = 0;
count = 0;
count = otherQueue.count;
maxQueueSize = otherQueue.maxQueueSize;
queueFront = otherQueue.queueFront;
queueRear = otherQueue.queueRear;
list = new Type[maxQueueSize];
assert (list != NULL);
for (int i = queueFront; i < queueRear; i++)
list[i] == otherQueue.list[i];
I understand that as element are deleted from the front of the queue and elements are added to the rear, the indices are advanced which is why I used queueFront and queueRear in the for loop, but that hasn't changed the garbage returned.
What have I not included?
Thanks for the help!