链表问题,求解
//错误的地方:将m_pHead复原之后,m_pHead->pNext == 0x00000000;求原因.自己没想出来
//没分了,只剩20分...
typedef struct _tgMONITOR_VERSION {
......
struct _tgMONITOR_VERSION pNext;
}tgMONITOR_VERSION;
int CConnection::IPlugInVersionNode(tgMONITOR_VERSION* pNode) {
long pSaveHead = (long)m_pHead; //保存头节点地址
while(m_pHead) { //循环进入最后的一个节点的pNext
m_pHead = m_pHead->pNext;
}
m_pHead = pNode; //将新节点保存在最后一个节点的pNext
m_pHead->pNext = NULL; //将新节点的pNext置0
m_pHead = (tgMONITOR_VERSION*)pSaveHead; //复原头节点地址
return 0;
}
m_pHead = (tgMONITOR_VERSION*)pSaveHead;