bool List::NextElem 代碼重復
bool List::NextElem(Node *pCurrentNode, Node *pNextNode) {}這個函數中 while(currentNode->next != NULL) {.........} return false; 和if(currentNode->next == NULL) {return false;} 真的不重復么??。?!
bool List::NextElem(Node *pCurrentNode, Node *pNextNode) {}這個函數中 while(currentNode->next != NULL) {.........} return false; 和if(currentNode->next == NULL) {return false;} 真的不重復么??。?!
2017-09-01
舉報
2019-05-24
最后一個節點是沒有后續節點的,所以要進行判空,不然會空指針異常,至于while里的是判斷循環結束的條件。
2017-09-01
前面是為了找到要找的結點,后面是防止該結點是最后一個結點。