求大神, c++的問題
bool List::GetElem(int i, Node *pNode)
{
if (i < 0 || i >= m_iLength)
{
return false;
}
Node *currentNode = m_pList;
Node *currentNodeBefore = NULL;
for (int k = 0; k <= i; k++)
{
currentNodeBefore = currentNode;
currentNode = currentNode->next;
}
}
沒寫完, 鏈表, 為什么要加一個臨時結(jié)點currentNodeBefore 直接currentNode = currentNode->next 循環(huán)到第i個位置不就行了, 干嘛多此一舉
2017-04-17
確實只是復(fù)制過來快一點
2017-04-01
確實多此一舉,可能是從取前一個節(jié)點的函數(shù)定義里拷貝過來的吧