c++中三目表达式问题

img


请问这里的三目表达式在c++中哪里有问题啊?
具体的错误列表:

img

整体代码:


#include
using namespace std;
struct ListNode
{
    int val;
    ListNode* next;
    ListNode(int val = 0, ListNode* next = nullptr) :val(val), next(next)//父类中是需要进行显示调用构造函数的
    {

    }
};
class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        if (head == nullptr)
            return nullptr;
        ListNode* cur = head;
        while (cur)
        {
            static  ListNode* next = cur->next->next;
            static ListNode* prev = cur->next;
            prev->next = cur;
            cur->next = next;
            cur = next;
        }
        ListNode* res = cur == nullptr ? prev : cur;
        return res;
    }
};
int main()
{
    Solution a;
    ListNode* newnode = new ListNode(0, nullptr);
    a.swapPairs(newnode);


    return 0;
}
ListNode* res = (cur == nullptr) ? prev : cur;