回復“qq_開心果_73981226”給后面的人看到。delete只是將currentndoe指向的內存給回收了,并不是這個指針就不能用了。回收了的意思就是之后使用這個指針不能再對原來指向的這塊內存區域進行操作。指針變量是存放在棧中的,作用周期完了之后才會被回收。
2017-10-04
void deletePerson(List *pList){
Node node;
Person person;
int n;
cout<<"請輸入要刪除的序號:";
cin>>n;
cout<<"請輸入要刪除的姓名:";
cin>>person.name;
if (person.name!=node.date.name)
{
cout<<”姓名錯誤請重新輸入!"<<endl;
cout<<"請輸入要刪除的姓名:";
cin>>person.name;
}
node.date=person;
pList->ListDelete(n-1,&node);
}
Node node;
Person person;
int n;
cout<<"請輸入要刪除的序號:";
cin>>n;
cout<<"請輸入要刪除的姓名:";
cin>>person.name;
if (person.name!=node.date.name)
{
cout<<”姓名錯誤請重新輸入!"<<endl;
cout<<"請輸入要刪除的姓名:";
cin>>person.name;
}
node.date=person;
pList->ListDelete(n-1,&node);
}
2017-10-02
插入頭結點,不應該是插到鏈表最前面替代當前的頭結點嗎,老師講的好像是插到了頭結點之后。我覺得應該這樣寫:
newNode->Data = m_pList->Data;
newNode->next = m_pList->next;
m_pList->Data = pNode->Data;
m_pList->next = newNode;
newNode->Data = m_pList->Data;
newNode->next = m_pList->next;
m_pList->Data = pNode->Data;
m_pList->next = newNode;
2017-09-28