gpt4 book ai didi

c++ - 'delete' 函数之前的预期 Unqualified-Id

转载 作者:太空狗 更新时间:2023-10-29 19:43:54 26 4
gpt4 key购买 nike

我写了一个C++程序,出现了这个错误,我找不到原因。有谁能够帮我。这个函数用于从链表中删除第i个元素,我已经尽力了,但我找不到原因。

#include <cstdio>
#include <fstream>

using namespace std;

struct node
{
int value;
node * next;
};

typedef struct node list;

list* head = NULL;
int list_length = 0;

bool empty(){
return (head == NULL);
}

void delete(int i){
if(i>list_length) return;
if(empty()) return;

int count = 0;
list* curr = head;
while(curr != NULL && count < i-1){
curr = curr -> next;
count++;
}
list* temp = curr -> next;
curr next = temp -> next;
list_length--;
}

int main(){
}

最佳答案

您有一个名为 delete 的方法,但是 delete is a keyword in C++ .

关于c++ - 'delete' 函数之前的预期 Unqualified-Id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18871708/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com