c++, eclipse,字段无法解析

c++, eclipse, field could not be resolved

本文关键字:字段 eclipse c++      更新时间:2023-10-16

我正在用eclipse在cpp中实现模板二叉树,我遇到了麻烦。

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;
}

我得到错误"字段'left'无法解析"。怎么了?