Circular Linked List
Never mind I fixed it.
I just needed to add
1 2 3
|
cout<<current->data<<endl;
|
before line 8
you could also make a do-while loop.
also: please try to avoid that semicolons at the end of an if-statement and a while statement (except for a do-while where it is necessary)
1 2 3 4 5 6 7 8 9 10 11 12
|
void print(){
Node<T>* current = head;
if(head == NULL){
return;
}
do{
cout<<current->data<<endl;
current = current->next;
} while(current != head);
}
|
Topic archived. No new replies allowed.