Data Structure Using C++
Tree Data Structure
Tree Node Template
template<class t>
class treeNode
{
private:
t info;
treeNode<t> *left;
treeNode<t> *right;
public:
treeNode(t i);
void setInfo (t i);
t getInfo ();
void setLeft (treeNode<t> *);
treeNode<t>* getLeft ();
void setRight (treeNode<t> *);
treeNode<t>* getRight ();
};
template<class t>
treeNode<t>::treeNode(t i)
{
info=i;
left=NULL;
right=NULL;
}
template<class t>
void treeNode<t>::setInfo (t i)
{
info=i;
}
template<class t>
t treeNode<t>::getInfo()
{
return info;
}
template<class t>
void treeNode<t>::setLeft (treeNode<t> *ptr)
{
left=ptr;
}
template<class t>
treeNode<t> * treeNode<t>::getLeft()
{
return left;
}
template<class t>
void treeNode<t>::setRight (treeNode<t> *ptr)
{
right=ptr;
}
template<class t>
treeNode<t> * treeNode<t>::getRight()
{
return right;
}
Let me know in the comment section if you have any question.
Previous Post:
Tree Node In Data Structure Using C++
Comments
Post a Comment