I’m implementing template binary tree in cpp with eclipse and I have trouble.
template <class T> struct node{
T data;
struct node *left;
struct node *rigth;
};
template<class T> node* newnode(T d) {
struct node *ret = new(struct node());
ret->left = NULL; //err here
ret->right = NULL;//err here
ret->data = d; //err here
return ret;
}
I’m getting error “Field ‘left’ couldn’t be resolved.”. What’s wrong? Thanks in advance.
1 Answer