Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 22nd, 2006, 1:29 PM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 856
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
'NULL' was not declared in this scope

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.

Last edited by titaniumdecoy; Mar 22nd, 2006 at 1:42 PM.
titaniumdecoy is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC