/
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode next;
* ListNode(int x) : val(x), next(NULL) {}
* };
/
class Solution {
public:
void deleteNode(ListNode node) {
ListNode next = node->next;
node->val = next->val;
node -> next = next->next;
}
};
定义的next结点不是指针类型的,不应该写成next->val; 应该写成next.val
或者改成 ListNode *next;