Thread: How do I call these functions?

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    This inOrder appears to be decreasing. If you pass in 5 for value, and the first number in the list is 2, then 5 < 2 will be false, and we won't walk the list. Is it supposed to be increasing? (If so, then that < would need to become a >.)

  2. #17
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    Ohhh yeah good eye. I guess so, but like I said, I can't change it. I guess I'll just flip my data around and treat it as decreasing. Now just one more question...how do I implement the functions that have LListNode<Data>* as parameters?

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Todd88 View Post
    Ohhh yeah good eye. I guess so, but like I said, I can't change it. I guess I'll just flip my data around and treat it as decreasing. Now just one more question...how do I implement the functions that have LListNode<Data>* as parameters?
    Carefully. They would be just like any other parameters; since they are pointers, that means you can modify the LListNode being pointed to, etc.

  4. #19
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    I just don't know what to put there as a parameter. Is it just LListNode<int> node? Because it's complaining at me again :/

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You would need to pass a pointer to the node.

  6. #21
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    Sorry I have no idea how to do that.

  7. #22
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Just like you would pass a pointer to anything else: with &.

  8. #23
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    Remember I can't edit the header file. I'm not sure how to pass a pointer to a node when all I have to work with is my main function. I used the addToEnd function to create my list and therefore really don't even use nodes myself. I don't know how to do this part.

  9. #24
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What does editing the header file have to do with anything? Every variable has an address, that you can get by prefix the variable name with &. So if a function needs the address of a variable, you should give it the address of the variable.

    Note also, as you can see in the addToEnd function, that the new keyword gives you a pointer to a <whatever you created>.

  10. #25
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    I'm sorry I have had the worst time with pointers and passing parameters. I am great at everything else but I can't seem to get this point. It is so frustrating because I know it's the simplest thing in the world but I just can't get it. It really makes me so mad knowing that this is simple and I can't understand!!

    Edit::sorry it was just that simple. I just needed to create a node via LListNode<int>* node; and use that...I'm embarassed.
    Last edited by Todd88; 11-27-2008 at 12:30 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. minix system call pls help for project
    By porvas in forum Linux Programming
    Replies: 2
    Last Post: 06-14-2009, 02:40 AM
  2. seg fault with any function call
    By LegoMan in forum C Programming
    Replies: 5
    Last Post: 04-15-2009, 05:30 PM
  3. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  4. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  5. Expression Manipulator v0.2 (bug fixes, functions)
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-26-2003, 04:52 PM