Reputation: 24304
I am building a tree data structure, in which I have an array of pointers in every node (node* children[FIXED_SIZE]
), that point to children (size of the array is fixed):
I want to have a child inside the child
variable (without freeing memory associated with it) but I also want to delete link between parent and children. Am I doing it correctly?
node* child = NULL;
i=2;
child = parent->children[i];
parent->children[i] = NULL;
Upvotes: 3
Views: 58
Reputation: 70901
Am I doing it correctly?
Assuming 2
is less then FIXED_SIZE
, your code looks ok.
Referring your wording:
I want to have a child inside the child variable
child
does not "have a child inside" but references, points to one.
Upvotes: 2