Hey everyone, I am back again (hopefully for the last time) 😛
My question this time: is there a way to get the memory address of an object from within that object? (if that makes sense).
For example, i am building a tree, and have an Add_Child(Object& o) function. When this function is called, i want it to save a pointer to the newly added child (i have done this part, and it works), but also to set the newly added childs "Parent" to the current object.
What i am currently doing is i have another method Set_Parent(Object& o), and am calling that method something like this (it may not be exactly how i have it, sorry. I don't have the come in from of me):
newChild.Set_Parent(*this);
This will compile just fine, and i can navigate down the tree from parent to child, however, when i try to go back up the tree (from child to parent) i get a segmentation fault.
Any ideas? Thanks in advance
EDIT: I have done some more searching, and realized that i think i can just let the recursion handle moving back up through the tree (D'oh!) assuming i can build the tree using a recursive method (my brain hurts, ill tackle that one tomorrow). However, for future reference do you know if there is still a way to get the memroy from the current object?
My question this time: is there a way to get the memory address of an object from within that object? (if that makes sense).
For example, i am building a tree, and have an Add_Child(Object& o) function. When this function is called, i want it to save a pointer to the newly added child (i have done this part, and it works), but also to set the newly added childs "Parent" to the current object.
What i am currently doing is i have another method Set_Parent(Object& o), and am calling that method something like this (it may not be exactly how i have it, sorry. I don't have the come in from of me):
newChild.Set_Parent(*this);
This will compile just fine, and i can navigate down the tree from parent to child, however, when i try to go back up the tree (from child to parent) i get a segmentation fault.
Any ideas? Thanks in advance

EDIT: I have done some more searching, and realized that i think i can just let the recursion handle moving back up through the tree (D'oh!) assuming i can build the tree using a recursive method (my brain hurts, ill tackle that one tomorrow). However, for future reference do you know if there is still a way to get the memroy from the current object?