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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置