| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 846 人关注过本帖
标题:[求助]看看二叉树的构造,算法没有问题,程序哪里不合理呢
只看楼主 加入收藏
cpluslover
Rank: 1
等 级:新手上路
威 望:1
帖 子:91
专家分:0
注 册:2006-12-13
收藏
 问题点数:0 回复次数:1 
[求助]看看二叉树的构造,算法没有问题,程序哪里不合理呢

#ifndef bitree1_h
#define bitree1_h

typedef char ElemType;
struct BiNode
{
ElemType data;
BiNode* lchild;
BiNode* rchild;
};
class BiTree
{
public:
BiTree(BiNode* root);
~BiTree();
void Preorder(BiNode *root);
void Postorder(BiNode *root);


private:
BiNode *root;
void Creat(BiNode *root);
void Release(BiNode *root);
};
#endif

#include "bitree.h"
#include"iostream.h"

//二叉树构造 函数的调用 函数
void BiTree::Creat(BiNode* root)
{
ElemType ch;
cout<<"please enter the data:"<<endl;
cin>>ch;
if(ch=='#') root=NULL;
else
{
root=new BiNode;
root->data=ch;
Creat(root->lchild);
Creat(root->rchild);

}
return;

}
//二叉树的析构函数的调用函数
void BiTree::Release(BiNode* root)
{
if(root!=NULL)
{
Release(root->lchild);
Release(root->rchild);
delete root;
}
}
//二叉树的构造函数
BiTree::BiTree(BiNode* root)
{
Creat(root);

}
//二叉树的析构函数
BiTree::~BiTree()
{
Release(root);
}


#include <iostream.h>
#include "bitree.h"

int main()
{
BiNode* room=0;
BiTree mytree(room);
return 0;
}

Linking...
ceshi.obj : error LNK2001: unresolved external symbol "public: __thiscall BiTree::~BiTree(void)" (??1BiTree@@QAE@XZ)
ceshi.obj : error LNK2001: unresolved external symbol "public: __thiscall BiTree::BiTree(struct BiNode *)" (??0BiTree@@QAE@PAUBiNode@@@Z)
Debug/ceshi.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

搜索更多相关主题的帖子: 二叉树 算法 构造 合理 
2007-03-21 23:08
wfpb
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2188
专家分:0
注 册:2006-4-2
收藏
得分:0 

算法是没有问题,但是参数名字最好不要和成员变量一样。


[glow=255,red,2]wfpb的部落格[/glow] 学习成为生活的重要组成部分!
2007-03-22 10:30
快速回复:[求助]看看二叉树的构造,算法没有问题,程序哪里不合理呢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016192 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved