📄 2叉树接点.txt
字号:
// BinNode.h: interface for the BinNode class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BINNODE_H__5C56371A_AA41_4B27_AB7D_CED16DA8F754__INCLUDED_)
#define AFX_BINNODE_H__5C56371A_AA41_4B27_AB7D_CED16DA8F754__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include"Link.h"
template <class T>
class BinaryTreeNode{
public:
BinaryTreeNode(){data=0;LeftChild =RightChild=0;}
BinaryTreeNode(const T& e)
{data = e;LeftChild = RightChild=0;}
BinaryTreeNode(const T& e, BinaryTreeNode<T> *l,BinaryTreeNode<T> *r)
{
data = e;
LeftChild = l;
RightChild = r;
}
T val();
void setVal(const T);
BinaryTreeNode<T>* left();
BinaryTreeNode<T>* right();
void setLeft(BinaryTreeNode<T> *);
void setRight(BinaryTreeNode<T> *);
bool isLeaf();
private:
T data;
BinaryTreeNode<T> *LeftChild,*RightChild;
};
#endif // !defined(AFX_BINNODE_H__5C56371A_AA41_4B27_AB7D_CED16DA8F754__INCLUDED_)
// BinNode.cpp: implementation of the BinNode class.
//
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
template <class T>
T BinaryTreeNode<T>::val()
{
return data;
}
template <class T>
void BinaryTreeNode<T>::setVal(const T e)
{
data=e;
}
template <class T>
BinaryTreeNode<T>* BinaryTreeNode<T>::left()
{
return LeftChild;
}
template <class T>
BinaryTreeNode<T> * BinaryTreeNode<T>::right()
{
return RightChild;
}
template <class T>
void BinaryTreeNode<T>::setLeft(BinaryTreeNode<T> * left)
{
LeftChild=left;
}
template <class T>
void BinaryTreeNode<T>::setRight(BinaryTreeNode<T> * right)
{
RightChild=right;
}
template <class T>
bool BinaryTreeNode<T>::isLeaf()
{
return (LeftChild==NULL)&&(RightChild=NULL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -