#include
using namespace std;
class binary_tree_node
{
public:
binary_tree_node(const int& init_data = int(),binary_tree_node*init_left=NULL,binary_tree_node* init_right=NULL)
{
data_field = init_data;
left_field = init_left;
right_field = init_right;
}
int& data(){return data_field;}
binary_tree_node* left(){return left_field;}
binary_tree_node* right(){return right_field;}
void set_data(const int& new_data){data_field=new_data;}
void set_left(binary_tree_node* new_left){left_field=new_left;}
void set_right(binary_tree_node* new_right){right_field=new_right;}
const int& data() const {return data_field;}
const binary_tree_node* left() const{return left_field;}
const binary_tree_node* right() const{return right_field;}
bool is_leaf()const{return (left_field==NULL)&&(right_field==NULL);}
bool is_left()const{return (left_field==NULL);}
bool is_right()const{return (right_field==NULL);}
private:
int data_field;
binary_tree_node* left_field;
binary_tree_node* right_field;
};
void main()
{
binary_tree_node* p;
cout<is_leaf()<<endl;
}
c++ 二叉树 access violation?链表不也是这样的吗?为什么以下代码会出错
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。