我无法理解这一行:
rear->next = temp;
在这个队列函数中:
void Queue::enqueue(int data) {
Node *temp = new Node(); // make a temporary node
temp->info = data; // assign passed in data to it
temp->next = 0; // make it point to null
if(front == 0) // if there is no front node
front = temp; // make this a front node
else // else, if there is already a front node
rear->next = temp; // make this rear's next pointer???? why?
rear = temp; // in any case make this a rear node
}
这样做不是更有意义吗?
else // else, if there is already a front node
temp->next = rear; // make temp point to REAR; not other way around
rear = temp; // make temp a new rear node