我正在做一个项目,我必须每天从队列中弹出 3 个学生。我的 popFront 函数似乎运行良好——因为它打印出正确的学生,但随后我的程序崩溃了。任何人都知道我的函数中是否有可能导致我的程序崩溃的东西?
void pop_front()
{
int num = 0;
if (front == NULL){
cout<<"No students to pop "<<endl;
return;
}
string value;
while(num<3)
{
Node *temp = front;
if(front->next)
{ value = front->name;
front = front->next;
front->prev = NULL;
size--;
delete temp;
cout<<value<<" ";
num++;
continue;
}
value=front->name;
front = NULL;
back = NULL;
delete temp;
cout<<" Last student in Priority1 list is: "<<value;
break;
}
}