P
PengYu.UT
Hi,
I'm reading an R-tree implementation converted from C to C++. A union
is used for the internal nodes and the leaves of the tree.
union
{
Node* m_child; ///Child node, if it
is an internal node
DATATYPE m_data; ///Data, if it is a leaf.
};
My feeling is that union is not used in C++ very often. union can be
removed by using polymorphism. I'm wondering for this tree application
whether it is better to use polymorphism rather than union. When I
shall do it the other way?
Thanks,
Peng
I'm reading an R-tree implementation converted from C to C++. A union
is used for the internal nodes and the leaves of the tree.
union
{
Node* m_child; ///Child node, if it
is an internal node
DATATYPE m_data; ///Data, if it is a leaf.
};
My feeling is that union is not used in C++ very often. union can be
removed by using polymorphism. I'm wondering for this tree application
whether it is better to use polymorphism rather than union. When I
shall do it the other way?
Thanks,
Peng