Queue implementation issue

why the given code in which i have implemented queue using linked list is not giving the correct output?
#include
using namespace std;
//implementation of queue using linked list
struct node{

int data;
node *next;
public:
node(int data){
this->data=data;
next=NULL;
}
};

struct queue{
private:
node *head;
node * front;
node *rear;
public:
queue(){
head=NULL;
front=head;
rear=head;
}

bool empty(){
return head==NULL;
}

void enqueue(int data){
node *n=new node(data);
if(empty()){
head=n;
rear=head;
front=head;
cout<data<<endl;
return;
}

    rear->next=n;
    rear=rear->next;
    cout<<rear->data<<endl;
}

void dequeue(){
if(!empty()){
cout<data<<endl;
node *temp=front;
head=head->next;
front=front->next;
delete temp;

    //cout<<front->data<<endl;
}}

int getfront(){
return front->data;
}
void print(){
node *temp=head;
while(head!=NULL){
    cout<<head->data<<"->";
    head=head->next;
}}
};

int main(){
queue q;
for(int i=48;i<56;i++){
    q.enqueue(i);
}
q.print();
while(!q.empty()){
    cout<<q.getfront()<<endl;
    q.dequeue();
}
return 0;
}

do not give the impelmentation using #include which is already included in the course

In the print function iteration in the while loop has to done using the temp pointer, if u are iterating it using the head pointer the head pointer reached the end, and is not longer pointing to the head node.
try replacing head with temp.

There is an error in this line data of which node are u trying to print.

In case of further doubts, do ask.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.