단일 순환 링크 목록에서 모든 노드를 제거하려고합니다. 하지만 다음있어 오류 :C++ 순환 링크 목록 - 모든 노드 제거
이void StudentLinkList::removeAll() {
StudentData *traversePointer = this->head;
while (this->head != nullptr) {
this->head = this->head->getNext();
delete traversePointer;
traversePointer = nullptr;
traversePointer = this->head;
this->size--;
}
}
내가이 줄에 오류 :
malloc: *** error for object 0x1005068f0: pointer being freed was not allocated
다음은 함수
delete traversePointer;
내 질문은 그 traversePointer 루프 동안의 할당되지 않은 이유 오류에 표시된대로?
, 그러나 당신의 질문은 무엇입니까? – user463035818
순환 링크리스트에서, 'this-> head = this-> head-> getNext();'는 처음으로 돌아 왔을 때 어떻게 동작할까요? 디버거를 사용하십시오 .... –
오류는 매우 솔직하게 설명력이 있습니다 ... 당신은 정말 기뻐해야합니다 ... 나는 이런 종류의 오류를 받았으면 좋겠어 ... – WhiZTiM