-3
我想知道這個代碼是否正確刪除第一個節點,或者我應該一定通過列表的頭指針?刪除鏈表(C++)的第一個節點
void List::deleteFirst()
{
temp = head;
head = head->next;
delete temp;
}
這是類List
class List
{
private:
struct node
{
int data;
node * next;
};
node * head;
node * curr;
node * temp;
public:
//List();
//void AddNode(int addData);
//void DeleteNode(int delData);
void deleteFirst();
//void PrintList();
};