I just have a quick question about how you would print the last element in a queue. Here is what I have so far:
struct queue {
node * head;
node * tail;
};
void printQ(queue & q) {
node * p = q.head;
cout << "QUEUE: ";
if (q.head == NULL)
cout << "empty";
while (p != NULL)
{
cout << p->key << " ";
p = p->next;
}
cout << " TAIL=" << ?????? // This is where I would like to
get it to print the tail but I'm not
sure how.
Thanks!