I wrote a C++ program, this error appeared and I can not find the cause. Can anybody help me. This function is used to delete element i-th from a linked list, even tried my best but I can't find the reason.
#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(){
}
You have a method called delete but delete is a keyword in C++.
delete
is a reserved keyword in C++. You have to rename your function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With