求一可用的define.h
来源:百度知道 编辑:UC知道 时间:2024/06/27 15:28:54
需要完整的代码,谢谢噢
二叉树模板实现
//纯头文件”bitnod.h”一个二叉树的完整模板代码,
//我们在用模板实现一个类时,最好用一个头文件一次性实现完毕,编译器连接时不会出错
//如果实现部分放在另一个CPP文件中,经常到编译连接的时候会过不去
//bitnod.h
#ifndef BITREE_H
#define BITREE_H
template<typename elemtype> class bitnode
{
public:
bitnode();//构造函数
bitnode( const bitnode<elemtype>& );//拷贝构造函数
const elemtype date () const;//读取数据
const bitnode<elemtype> *lchild () const;//返回左指针
const bitnode<elemtype> *rchild () const;//返回右指针
void get_date( const elemtype );//输入数据
void get_lchild ( const bitnode<elemtype>* );//输入左指针
void get_rchild ( const bitnode<elemtype>* );//输入右指针
void operator =( const bitnode<elemtype>& );//赋值
private:
elemtype _date;//节点数据
bitnode<elemtype> *_lchild,*_rchild;//左右孩子指针
};//二叉树的节点
//bitnode