My error is regarding the last two assignment statements in main. I am trying to create a basic tree by having each node point to 2 other nodes: left and right. I have also tried adding * in front of n1, n2, and n3 when creating them, but that did not work either...
#include <iostream>
#include <string.h>
using namespace std;
class Node{
public:
string value;
Node *left, *right;
public:
Node(string s, Node *l, Node *r){
value = s;
left = l;
right = r;
}
void display(){
cout << value << left->value << right->value;
}
};
int main(){
Node n1("this", NULL,NULL);
Node n2("is", NULL, NULL);
Node n3("next", NULL, NULL);
n1.left = n2;
n1.right = n3;
n1.display();
return 0;
}