编译代码时出错

Error while compiling the code

本文关键字:出错 代码 编译      更新时间:2023-10-16

我在编译时收到一条错误消息,说

node.h: In member function ‘void binary_tree::print(node*&, std::ofstream&)’:
node.h:17:10: error: ‘node* node::left_child’ is private

但是在node.h中,成员是公共

class node {
  public:
    char *word;         
    int frequency;
    node  *left_child;              
    node *right_child; };

使用MinGW进行构建和运行。请帮我解决这个问题。

您需要提交完整的代码以获得评论。

  1. 如果left_child是公共的,则不会发生错误。您可以清理和重新生成代码
  2. binary_tree这个类是如何使用类节点的

它运行得很好!!!但这里出现了一些构建错误。这是修改后的代码https://drive.google.com/file/d/0B5PwxyqEos-wb05vRzhvN21aYTQ/edit?usp=sharing