enqueue and dequeue pointer
I'm trying to create a menu style enqueue and dequeue with pointers. I have this so far I want to use the left and right pointers to lets say dequeue a number. I also thought about using two temps. Any suggestions?
Code:
#include<iostream>
using namespace std;
struct qNode{
int num;
qNode *next;
qNode *left;
qNode *right;
};
int main(){
qNode *temp = NULL;
qNode *front = NULL;
qNode *back = NULL;
temp = new qNode;
temp->num = 7;
cout<<temp->num<<endl;
cout<<endl;
// cout<<temp<<endl;
front = temp;
back = front;
// cout<<"front: "<<front<<endl;
// cout<<"back: "<<back<<endl;
temp = new qNode;
temp->num = 9;
back->next = temp;
back = temp;
cout<<front->next->num<<endl;
temp = front;
while(temp){
cout<<temp->num<<endl;
temp = temp->next;
}
front = front->next;
delete temp;
return 0;
}