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