Код: Выделить всё
class Queue{
public: Queue(Queue* i, edge* c): next{i}, cur{c}{}
public: edge* cur;
public: Queue* next;
public: void pop(){
if(next==0){cur=0; return;} //Tried changing this already, didn't work
Queue* a =next;
next=next->next;
cur=next->cur;
free(a);
}
//insert logic
}
//Other stuff
printf("NextCur: %d", q.next->cur->s); //This resolves fine
q.pop();
printf("NextCur: %d", q.cur->s); //This decides to die
Обратите внимание, что это не тот случай, когда выталкивается последний элемент - как видно из printf, в списке есть еще один элемент. Я убедился, что проблема не в предложении if.
Подробнее здесь: https://stackoverflow.com/questions/798 ... ont-get-it
Мобильная версия