bintree.h

来自「经典c++程序的实现」· C头文件 代码 · 共 24 行

H
24
字号
class BinNode {                // Binary tree node class
public:
  BELEM element;               // The node's value
  BinNode* left;               // Pointer to left child
  BinNode* right;              // Pointer to right child  
  static BinNode* freelist;
  // Two constructors -- with and without initial values
  BinNode() { left = right = NULL; }
  BinNode(BELEM e, BinNode* l =NULL, BinNode* r =NULL)
    { element = e; left = l; right = r; }
  ~BinNode() { }               // Destructor
  BinNode* leftchild() const { return left; }
  BinNode* rightchild() const { return right; }
  BELEM value() const { return element; };
  void setValue(BELEM val) { element = val; }
  bool isLeaf() const          // Return TRUE if is a leaf
    { return (left == NULL) && (right == NULL); }
  void* operator new(size_t);  // Overload new  
  void operator delete(void*); // Overload delete
};

// This creates space for the freelist variable

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?