1
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <fstream>
#include <string>
using namespace std;
class Node
{
public:
string word;
Node *left;
Node *right;
Node *parent;
int number;
int balance;
int height;
Node(string x);
Node(string x, Node *nleft, Node *nright);
Node(string, Node *nparent, Node *nleft, Node *nright);
void setWord(string x);
string getWord();
void setParent(Node *nparent);
Node getParent();
void setLeft(Node *nleft);
Node getLeft();
void setRight(Node *nright);
Node getRight();
void setNumber(int num);
int getNumber();
};
Node::Node(string x){
word = x;
parent = NULL;
left = NULL;
right = NULL;
number = 1;
balance = 0;
height = 0;
}
Node::Node(string x, Node *nleft, Node *nright){
word = x;
parent = NULL;
left = nleft;
right = nright;
number = 1;
balance = 0;
height = 0;
}
Node::Node(string x, Node *nparent, Node *nleft, Node *nright){
word = x;
parent = nparent;
left = nleft;
right = nright;
number = 1;
balance = 0;
height = 0;
}
void Node::setWord(string x){
word = x;
}
string Node::getWord(){
return word;
}
void Node::setParent(Node *nparent){
parent = nparent;
}
Node Node::getParent(){
return parent;
}
void Node::setLeft(Node *nleft){
left = nleft;
}
Node::Node getLeft(){
return left;
}
void Node::setRight(Node *nright){
right = nright;
}
Node::Node getRight(){
return right;
}
void Node::setNumber(int num){
number = num;
}
int Node::getNumber(){
return number;
}
我試圖在eclipse中的AVL樹中創建我的節點類,我想知道爲什麼錯誤沒有可行的從'Node *'轉換爲'節點'爲我的getters被返回安慰。什麼是最好的解決和解決這個問題的原因。AVL搜索樹