The code above has a class that defines the nodes in the very basic integer based linked list, a function to create the linked list using multiple instances of the nodes, and a function to traverse through the entire list, counting the total number of nodes in the list. I do know about the memory leaks that can arise due to unresolved pointer variables.
The trouble comes in when I run the total function. It gives me back a value of 1, and not anything more. I suspect it's because the function that creates the linked list cannot return multiple instances of the node at a time.
The Question: Is there a way to correct this problem without me having to modify the node class? Thanks for answering! :D
Sorry for the long wait for my reply, I thought they would send me any emails about any new activity...
I did implement the ptr variable in line 9, didn't I? Unless you mean pointing it to a temporary address or 0...
Okay, let me rephrase the question: If there exists a pointer 'A' that points to another pointer 'B', which in turn points to a unrelated object 'C', can I use the return function such that the line "return A" will return the whole group? Or is there another way to do such a thing...or none at all? :o
Sorry for the long wait for my reply, I thought they would send me any emails about any new activity...
See the "Tracking options for this topic:" at the bottom of the thread.
I did implement the ptr variable in line 9, didn't I? Unless you mean pointing it to a temporary address or 0...
What he said was: ptr is not modified anywhere in your program... and that's what he meant. It is never set to point to a valid memory address, but you treat it as if it were. Search your code for "setpointer", since that is the only way to modify ptr. Where do you see it called?