Thread: Calculator + LinkedList

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    read xeraths comment. it says it all. You use a list thats not there. fFirts is NULL on first use so temp is also NULL. This is your problem.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  2. #2
    Registered User
    Join Date
    Apr 2005
    Posts
    18
    Quote Originally Posted by Stoned_Coder
    read xeraths comment. it says it all. You use a list thats not there. fFirts is NULL on first use so temp is also NULL. This is your problem.
    yes Stoned_Coder
    i think that's it
    there is no LinkedList object , so i have to creat it it first , but the my problem now that in the Main function i call Calculator Object ,, but i don't get it to start the program using LinkedList Object
    thanks

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    if (isEmpty())
    	{
    		fFirst->setNext(data);
    	}
    If this is in fact empty, which by definition means that 'fFirst' is null, then how can you be calling 'fFirst->setNext(data)'? You're trying to access a null pointer there. That's bad.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Apr 2005
    Posts
    18
    Quote Originally Posted by quzah
    Code:
    if (isEmpty())
    	{
    		fFirst->setNext(data);
    	}
    If this is in fact empty, which by definition means that 'fFirst' is null, then how can you be calling 'fFirst->setNext(data)'? You're trying to access a null pointer there. That's bad.

    Quzah.
    hi quzah
    but it's the same when you creat a new object you set the pointers to NULL then you let them point to what ever

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're missing the point. If a pointer 'fFirst' is in fact null, then you cannot dereference it to access one of its members. Thus, 'fFirst' has no 'setNext()' function, because you have no instance of 'fFirst'. Create an instance, make 'fFirst' point to it, and then you can access 'fFirst->whatever'. But until you have an instance that you're actually pointing to, you cannot use its members (unless they're static, but that's another issue entirely).

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed