Queue

I can't get the program to dequeue properly. I can't get front to store next
after the current front is deleted. Can anyone help me figure out what I am doing wrong?

Last edited on
1
2
3
4
5
6
7
template <class T>
int DynIntQueue<T>::dequeue(){
if(front->node==NULL){ //¿ where did you set any value to front->node ?
        front->data=NULL;
        numNodes=0;
        return numNodes;
    }else
This program was originally for stack and now I am trying to convert it to a queue.
Last edited on
In DynIntQueue constructor you assign front->node=NULL;
After that there is no operation that will change the value of front->node
So
1
2
3
4
5
6
7
8
9
10
11
12
13
14
template <class T>
int DynIntQueue<T>::dequeue(){
if(front->node==NULL){ //tautology
        front->data=NULL;
        numNodes=0;
        return numNodes;
    }else{ //never executes
        Node<T> *temp;
        temp=front->node;
        delete front;
        front=temp;
    }
    return --numNodes;
}


There is no coherence between dequeue and enqueue
Last edited on
What should the if condition be because I get an exception violation when I change the if condition?
Exception: STATUS_ACCESS_VIOLATION at eip=00401F53
Last edited on
Topic archived. No new replies allowed.