123456789101112
int LinkedList::GetLength() { int count = 0; Node* temp = head; while (temp!=0) { count++; temp = temp->next; } //cout << count; <-- this works return count; }
cout << yourList.GetLength();
1234567891011121314
5 7 9 11 5 5 7 9 11 5 7 Press any key to continue . . .
5 7 9 11 5 5 7 9 11 5 7 6Press any key to continue . . . //notice the 6 over there?