I have a class Node:
class Node { public: int item; Node * nextLink; }; Outside a function I declare a Node pointer:
Node * newNode; Then, I pass this pointer to a function foo:
void foo(Node * node) { node = new Node(); node->item = 1; Node * anotherNode = new Node(); anotherNode->item = 2; node->nextLink = anotherNode; } Actual call:
foo(newNode); At the end of foo (but before existing) I can see that node->item and node->nextLink point to the correct places. However, when returned from foo, I check newNode, and the item is correct, but the nextLink is not there.
Any suggestions? Thanks