you are implementing circular queue,
property of circular queue is last node should points to first node means, rear->link=front.
for better understanding, let new node = A
a new node is inserted at last, therefore
1) A = new node() =====> Rear -> link = new node()
update its value
2) A->data = x; =====> Rear -> link ->data = x;
last element, next pointer should points to front
3) A->link = front =====> rear->link->link = front
therefore your last element changed, therefore you have to change the pointer
4) rear=A =====> rear=rear->link
a new node is inserted at last, therefore
1) A = new node() =====> Rear -> link = new node()
update its value
2) A->data = x; =====> Rear -> link ->data = x;
therefore your last element changed, therefore you have to change the pointer
3) rear=A =====> rear=rear->link
last element, next pointer should points to front
4) A->link = front =====> rear->link = front