C++ 我有一个C++;在Dev C++;但不是在G++;

C++ 我有一个C++;在Dev C++;但不是在G++;,c++,linked-list,C++,Linked List,我的主函数调用linkedlist中的remove函数 case 7: input >> argument; cout << "Attempting to remove " << argument << endl; if(myList.remove(argument)) { cout << "Successfully removed the element from the list\n

我的主函数调用linkedlist中的remove函数

 case 7:
    input >> argument;
    cout << "Attempting to remove " << argument << endl;
    if(myList.remove(argument))
    {
        cout << "Successfully removed the element from the list\n";
    }
    else
    {
        cout << "Could not remove the element from the list\n";
    }
    break;
此函数用于搜索值为num的节点,如果找到,将从列表中删除该节点

        node* second = head;
        node* first = head->next;
        if (head == NULL)
        {
            return;
        }
        else if (head->val == num)
        {
            node* temp = head;
            head = head->next;
            delete temp;
        }   


        while (first&&first->val != num)
        {
            second = first;
            first = first->next;
        }
        if (first)
        {
            second->next = first->next;
            delete first;
        }

    }

错误在于无法将
myList
void
中删除
参数转换为
BOOL
,但我调用的是什么,它认为是
BOOL
函数?我没有传回
true
false
值。

问题是
remove
被声明为
void
函数,并且它不返回值。所以不能在
if()
语句中使用它,因为它不会返回可以转换为布尔值并进行测试的值

取出调用
myList前后的
if()
。删除(参数)

案例7:
输入>>参数;

cout确切的错误消息是什么,它指向哪一行?在函数“int main()”中:main.cpp:66:29:错误:如果(myList.remove(argument))严重,则无法将“myList.LL::remove(argument)”从“void”转换为“bool”,你有一个C++程序,你用C++编译器,你认为最好的语言标签是C和C,它是在C++和LINKEDistLeGez中加标签的,我取出了如果是声明,那么G++就真正地吹响了Me.CPP未定义的引用,将LL:L.()定义为LL:Prime:(int)'Meun.CPP未定义的引用:LL:(int)'etc.@KristoferBeck不会通过引入另一个问题来解决问题。询问这个问题,而不是您尝试的解决方案。@KristoferBeck您一定做了一些事情,而不仅仅是删除通话中的
if
。我已经编辑了答案,以显示它应该是什么样子。
    #include "ll.h"
    LL::LL()
    {
        head = NULL;
    }
    void LL::remove(int num){
        node* second = head;
        node* first = head->next;
        if (head == NULL)
        {
            return;
        }
        else if (head->val == num)
        {
            node* temp = head;
            head = head->next;
            delete temp;
        }   


        while (first&&first->val != num)
        {
            second = first;
            first = first->next;
        }
        if (first)
        {
            second->next = first->next;
            delete first;
        }

    }
case 7:
    input >> argument;
    cout << "Attempting to remove " << argument << endl;
    myList.remove(argument);
    break;