Im製作一個雙向鏈表。錯誤是用我的刪除方法。我無法弄清楚這一點。有人知道嗎?DoublyLinkedList刪除錯誤
這裏是錯誤的地方?
錯誤1個錯誤C2027:使用未定義的類型 'DoublyListNode' C:\用戶\康納爾\文件\學院\ C++ \項目\重複 - doublylinkedlist \重複 - doublylinkedlist \ doublylinkedlist.h 230 1重複 - DoublyLinkedList
// -------------------------------------------------------------------------------------------------------
// Name: Remove
// Description: Removes the node that the iterator points to, moves iterator forward to the next node.
// Arguments: p_iterator: The iterator to remove
// isForward: Tells which direction the iterator was going through the list
// Return Value: None.
// -------------------------------------------------------------------------------------------------------
void Remove(DoublyListIterator<Datatype>& m_itr)
{
DoublyListNode<Datatype>* node = m_head;
// if the iteratordoesn’t belong to this list, do nothing.
if (m_itr.m_list != this)
return;
// if node is invalid, do nothing.
if (m_itr.m_node == 0)
return;
if (m_itr.m_node == m_head)
{
// move the iteratorforward and delete the head.
m_itr.Forth();
RemoveHead();
m_size--;
}
else
{
// scan forward through the list until you find
// the node prior to the node you want to remove
while (node->m_next != m_itr.m_node)
node = node->m_next;
// move the iterator forward.
m_itr.Forth();
// if the node you are deleting is the tail,
// update the tail node.
if (node->m_next == m_tail)
{
m_tail = node;
}
// delete the node.
delete node->m_next;
// re-link the list.
node->m_next = m_itr.m_node;
m_size--;
}
}
如果需要再代碼只問。我不想在堆棧溢出用戶上輸入很多代碼。
你看到的錯誤究竟是什麼?例如:編譯器/鏈接器,不希望的運行時行爲(具體)?還是SEGFAULT? – MartyE
你真的希望得到任何幫助,甚至沒有告訴我們錯誤是什麼?我們現在不需要更多的代碼,我們需要一個合適的標題和一個問題。 – stefan
apoogies。我複製並粘貼了標題。這樣做時我犯了一個錯誤。我編輯了我的代碼。你能否再認爲我的失望。 – Pendo826