0

複数のファイルを含むプログラムを作成していますが、tnode ファイルで cout<< を認識しません。誰でも問題の場所を特定できますか? 他のエラーの中でも、ノード ファイルに「cout はこのスコープで宣言されていませんでした」というエラーが表示されます。私の主な機能:

#include <iostream>
#include "bst.h"
using namespace std;



int main(int argc, char *argv[]) {
    cout<<"hi";
    bst *list = new bst();
    return 0;
}

私の BinarySearchTree ファイル:

#ifndef bst_H
#define bst_H
#include <iostream>
#include <string>
#include "tnode.h"



class bst
{
    public:

    bst()
    {
    root = NULL;
    }
void add(int key, char value) {
      if (root == NULL) {
            root = new tnode(key, value);
            return
      } else
            root->add(key, value);
            return
}






tnode *root;

};

#endif

私のノードファイル:

#ifndef tnode_H
#define tnode_H
#include <iostream>
#include <string>

class tnode
{
public:
    tnode(int key, char value)
    {
                this->key = key;
                this->value = value;
                N = 1;
                left = NULL;
                right = NULL;
                cout<<"hi";
    }

void add(int key, char value) {
      if (key == this->key)
      {
            cout<<"This key already exists";
            return;
      }
      else if (key < this->key)
       {
            if (left == NULL) 
            {
                  left = new tnode(key, value);
                  cout<<"Your node has been placed!!";
                   return;
            } 
            else
            {
                  left->add(key, value);
                  cout<<"Your node has been placed!";
                  return;
            } 
      }
       else if (key > this->key)
       {
            if (right == NULL) 
            {
                  right = new tnode(key, value);
                  cout<<"Your node has been placed!!"; return;
            } 
            else
                  return right->add(key, value);
       }
      return;
}
        tnode* left;
        tnode* right;
        int key;
        char value;
        int N;

};




#endif
4

2 に答える 2