📄 9-12.h
字号:
//9-12.h
#ifndef BINARYTREE_CLASS
#define BINARYTREE_CLASS
#include <iostream.h>
#include <stdlib.h>
#ifndef NULL
const int NULL = 0;
#endif // NULL
#include "9-11.h"
template <class T>
class binaryTree
{
public:
binaryTree(); //构造函数
~binaryTree(); //析构函数
bool isEmpty(); //判断树空否
TreeNode<T>* getroot() const; //取得根结点
protected:
TreeNode<T>* root;
};
//构造函数
template <class T>
binaryTree<T>::binaryTree()
{
root=NULL;
}
//析构函数
template <class T>
binaryTree<T>::~binaryTree()
{
if(root)
{
root->release(); //删除根结点的左右子树
delete root; //释放根结点
root=NULL;
}
}
//判断树空否
template <class T>
bool binaryTree<T>:: isEmpty()
{
return root==NULL;
}
//取得根结点
template <class T>
TreeNode<T>* binaryTree<T>::getroot() const
{
return root;
}
#endif // BINARYTREE_CLASS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -