Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 学生队伍由双LL组成_C++_Linked List_Queue - Fatal编程技术网

C++ 学生队伍由双LL组成

C++ 学生队伍由双LL组成,c++,linked-list,queue,C++,Linked List,Queue,我正在做一个项目,每天我要从一个队列中抽出3个学生。我的popFront函数似乎工作得很好——因为它打印出了正确的学生,但随后我的程序崩溃了。有人知道我的函数中是否有什么东西可能导致我的程序崩溃吗 void pop_front() { int num = 0; if (front == NULL){ cout<<"No students to pop "<<endl; return; } str

我正在做一个项目,每天我要从一个队列中抽出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;
        }

}
void pop_front()
{
int num=0;
if(front==NULL){

cout您编写的函数没有任何问题。您的程序可能由于代码中的其他函数而崩溃。请检查您是否尝试访问非法内存,即您在程序中的其他任何位置之前未分配的内存。

返回了什么,以及为什么只有在上次弹出student时才会更新。是否返回->next=front?如果是这样,那么它也应该被更新(temp->prev->next=temp->next或类似的sthf)。