我正在编写一个简单(非常简单)的链表来复习我的编程技能,但显然,我失败了,因为我遇到了这个编译器错误,而且我无法弄清楚出了什么问题。问题出在删除函数上:
bool delete(node* head, node* delMe){
node* current;
if(delMe == head){
if(head->next != NULL){
head = delMe->next;
free(delMe);
}else{
head = NULL;
cout<<"There are no more elements in the LL"<<endl;
}
return true;
}else{
current = head;
while(current){
if(current->next == delMe){
current->next = delMe->next;
free(delMe);
return true;
}
current = current->next;
}
}
return false;
}
我在“删除”之前得到了预期的不合格 ID。
我以为它可能是它上面的插入函数,但是当我完全注释掉删除函数时,程序编译没有问题。
最佳答案
delete
是 C++ 中的关键字。您不能将其用作标识符。
关于c++ - bool 函数之前预期的不合格 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15181958/