T
Tomek
Hello,
lets say i have some structure
struct Node {
int key ;
Node *left, *right ;
}
then in main() i declare pointer to structure like this
Node *root = NULL ;
then i want to send this pointer to function which will
add new Node, definition of this function looks like this:
void AddNode(Node *root) {
Node *anothernode = new Node ;
anothernode->left = anothernode->right = NULL ;
if( root == NULL )
root = anothernode ;
// ok rest code is not important here
}
the main problem is when i return from function AddNode
my pointer called "root" doesnt remember address of pointer
"anothernode", any idea why ?
Thanks in advance,
Regards
tommy
lets say i have some structure
struct Node {
int key ;
Node *left, *right ;
}
then in main() i declare pointer to structure like this
Node *root = NULL ;
then i want to send this pointer to function which will
add new Node, definition of this function looks like this:
void AddNode(Node *root) {
Node *anothernode = new Node ;
anothernode->left = anothernode->right = NULL ;
if( root == NULL )
root = anothernode ;
// ok rest code is not important here
}
the main problem is when i return from function AddNode
my pointer called "root" doesnt remember address of pointer
"anothernode", any idea why ?
Thanks in advance,
Regards
tommy