回復(fù)“qq_開心果_73981226”給后面的人看到。delete只是將currentndoe指向的內(nèi)存給回收了,并不是這個(gè)指針就不能用了?;厥樟说囊馑季褪侵笫褂眠@個(gè)指針不能再對(duì)原來指向的這塊內(nèi)存區(qū)域進(jìn)行操作。指針變量是存放在棧中的,作用周期完了之后才會(huì)被回收。
2017-10-04
void deletePerson(List *pList){
Node node;
Person person;
int n;
cout<<"請(qǐng)輸入要?jiǎng)h除的序號(hào):";
cin>>n;
cout<<"請(qǐng)輸入要?jiǎng)h除的姓名:";
cin>>person.name;
if (person.name!=node.date.name)
{
cout<<”姓名錯(cuò)誤請(qǐng)重新輸入!"<<endl;
cout<<"請(qǐng)輸入要?jiǎng)h除的姓名:";
cin>>person.name;
}
node.date=person;
pList->ListDelete(n-1,&node);
}
Node node;
Person person;
int n;
cout<<"請(qǐng)輸入要?jiǎng)h除的序號(hào):";
cin>>n;
cout<<"請(qǐng)輸入要?jiǎng)h除的姓名:";
cin>>person.name;
if (person.name!=node.date.name)
{
cout<<”姓名錯(cuò)誤請(qǐng)重新輸入!"<<endl;
cout<<"請(qǐng)輸入要?jiǎng)h除的姓名:";
cin>>person.name;
}
node.date=person;
pList->ListDelete(n-1,&node);
}
2017-10-02
插入頭結(jié)點(diǎn),不應(yīng)該是插到鏈表最前面替代當(dāng)前的頭結(jié)點(diǎn)嗎,老師講的好像是插到了頭結(jié)點(diǎn)之后。我覺得應(yīng)該這樣寫:
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
老師之前在線性表中,元素的刪除那個(gè)函數(shù)中有一行代碼字錯(cuò)了,導(dǎo)致刪掉的并不是第i個(gè)元素,而是第i-1個(gè)元素
2017-09-23
位置編碼這塊老師幾個(gè)函數(shù)好像都沒有統(tǒng)一啊,一會(huì)head算0位置,一會(huì)head又不算了
2017-09-23
== 運(yùn)算符重載 報(bào)錯(cuò)
二進(jìn)制“&&”:沒有找到接受"std::string"類型的全局運(yùn)算符(或沒有可接受的轉(zhuǎn)換)
二進(jìn)制“&&”:沒有找到接受"std::string"類型的全局運(yùn)算符(或沒有可接受的轉(zhuǎn)換)
2017-09-14