I keep getting the error "'NULL' was not declared in this scope" in all my C++ programs. From what I understand, 0 is the equivalent of NULL, but I am wondering why NULL does not seem to work.
I am working on a LinkedList class, and am having the problem that when I try to access the last ListNode in the list, the loop does not stop cycling through memory after it has reached the last ListNode. I am trying to compare the nodes to 0 (empty nodes have been initialized to 0 because NULL does not work). What am I doing wrong? Thanks.
int LinkedList::dequeue() {
ListNode *current = front;
while (current->next != 0) { // What should my test condition be?
current = current->next;
}
return current->value;
}
EDIT: I solved the problem, I had not initialized the front ListNode to 0.