错误:ISO c++禁止指针和整数[-fpermissive]的比较

Error: ISO C++ forbids comparison between pointer and integer [-fpermissive]

本文关键字:-fpermissive 比较 整数 ISO c++ 禁止 指针 错误      更新时间:2023-10-16
template <class ST>
bool OrderedSet<ST>::IsIn (const ST & value) const
{
    for (LNode * np = first; np != NULL; np = np -> next)
        if (np -> next == value)
            return true;
    return false;
}

我知道np->next是指针,而value不是。如果指定的数据值在集合中,我想返回true,如果该值不在集合中,我想返回false。

这一行

if (np -> next == value)
应该

if (np->data == value)

除了我们不知道你的data成员变量的名字