C
Christopher Pisz
currently my node is like so with everything public:
class Quadtree_Node
{
public:
Quadtree_Node(Quadtree_Node * parent, Bounding_Box & bounds);
~Quadtree_Node();
void Subdivide(float smallest_node);
const Quadtree_Node *& GetTopLeft();
Bounding_Box m_bounds; // Bounding Coordinates of this node
Quadtree_Node * m_parent; // Parent of this node, NULL if root
Quadtree_Node * m_tlchild; // Top Left child node
Quadtree_Node * m_trchild; // Top Right child node
Quadtree_Node * m_blchild; // Bottom Left child node
Quadtree_Node * m_brchild; // Bottom Right child node
std::list<Data> m_data; // Linked List of Data
};
And my deletion method looks like:
void Quadtree:elete(Quadtree_Node * node)
{
if(node)
{
Delete(node->m_tlchild);
Delete(node->m_trchild);
Delete(node->m_blchild);
Delete(node->m_brchild);
}
delete node;
}
How can I change this so that I can make my data members of class
Quadtree_Node private? I was thinking of making a GetFunction to get the
pointers to the children of the node, but then I am not sure if I would be
returning a copy of the pointer, a referance of the pointer or the pointer
itself for use in the deletion.
A try:
const Quadtree_Node *& GetTopLeft() {return m_tlchild;}
delete ->node->GetTopLeft();
Would that be safe?
Thanks,
Christopher
class Quadtree_Node
{
public:
Quadtree_Node(Quadtree_Node * parent, Bounding_Box & bounds);
~Quadtree_Node();
void Subdivide(float smallest_node);
const Quadtree_Node *& GetTopLeft();
Bounding_Box m_bounds; // Bounding Coordinates of this node
Quadtree_Node * m_parent; // Parent of this node, NULL if root
Quadtree_Node * m_tlchild; // Top Left child node
Quadtree_Node * m_trchild; // Top Right child node
Quadtree_Node * m_blchild; // Bottom Left child node
Quadtree_Node * m_brchild; // Bottom Right child node
std::list<Data> m_data; // Linked List of Data
};
And my deletion method looks like:
void Quadtree:elete(Quadtree_Node * node)
{
if(node)
{
Delete(node->m_tlchild);
Delete(node->m_trchild);
Delete(node->m_blchild);
Delete(node->m_brchild);
}
delete node;
}
How can I change this so that I can make my data members of class
Quadtree_Node private? I was thinking of making a GetFunction to get the
pointers to the children of the node, but then I am not sure if I would be
returning a copy of the pointer, a referance of the pointer or the pointer
itself for use in the deletion.
A try:
const Quadtree_Node *& GetTopLeft() {return m_tlchild;}
delete ->node->GetTopLeft();
Would that be safe?
Thanks,
Christopher