sirxiangsir 2015-11-11 15:55 采纳率: 3.7%
浏览 1427

哪位高手能给下面代码加上注释啊,我刚开始学,不太懂诶

#ifndef _MyTreeNode_h_
#define _MyTreeNode_h_
#include <iostream>
#include <string>
using namespace std;

class MyTreeNode {

  public:
    char data;  
    int weight;
    int isfather;
    bool isBianLi;
    char code;
    string codes;
    MyTreeNode* left;
    MyTreeNode* right;
    MyTreeNode* father;
    MyTreeNode (char data, int weight) {
        this->weight = weight;
        this->data = data;
        this->isBianLi = false;
        this->code = '0';
        this->codes = "";
        this->isfather = 0;
        this->father = NULL;
        this->left = NULL;
        this->right = NULL;
    }
    void SetChild (MyTreeNode* left, MyTreeNode* right) {
        this->left = left;
        this->right = right;
    }
    void SetFather(int isfather) {
        this->isfather = isfather;
    }
    void SetFather(MyTreeNode* father) {
        this->father = father;
    }

};

#endif
  • 写回答

2条回答 默认 最新

  • mifit 2015-11-12 01:23
    关注

    定义一个类MyTreeNode,
    里面有基本的类型data,weigth,isBianLi等。
    还有left,rigth,father。他们是指针,是二叉树的左右叉树和父叉树。
    还有构造函数MyTreeNode (char data, int weight) 和一些函数;每个类本身都有一个this指针,代表对象本身。
    像构造函数的data变量,与类本身的变量data是一样的,为了区分,加this。后面函数雷同。

    评论

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?