现在的位置: 首页 > 综合 > 正文

二叉树结点定义

2013年03月02日 ⁄ 综合 ⁄ 共 427字 ⁄ 字号 评论关闭

#ifndef TREENODE
#define TREENODE

// 表示二叉树的一个结点

template <typename T>
class tnode
{
   public:
  // tnode is a class implementation structure. making the
  // data public simplifies building class functions
  T nodeValue;
  tnode<T> *left, *right;

  // default constructor. data not initialized
  tnode()
  {}

      // initialize the data members
  tnode (const T& item, tnode<T> *lptr = NULL,
     tnode<T> *rptr = NULL):
     nodeValue(item), left(lptr), right(rptr)
  {}
};

#endif // TREENODE

抱歉!评论已关闭.