在ListInsertHead(Node *pNode)和ListInsertTail(Node *pNode)函数中,可以直接对pNode进行链接操作,而不用新建newNode节点,如下代码所示,可以吗?
bool ListInsertHead(Node *pNode)
{
pNode->next=m_pList->next;
m_pList->next=pNode;
if(m_pList-next==pNode)
{
return true;
}
else
{
return false;
}
}
bool ListInsertTail(Node *pNode)
{
Node *currentNode=m_pList;
while(currentNode->next!=NULL)
{
currentNode=currentNode->next;
}
currentNode->next=pNode;
pNode->next=NULL;
if(currentNode->next==pNode)
{
return true;
}
else
{
return false;
}
}