-2
爲什麼這部分代碼無法在鏈表的末尾添加元素?如何在鏈表的末尾插入一個元素?
void insert_last(node **test, node **head){
*test = *head;
int value;
cout << "enter the value to be inserted:";
cin >> value;
node *temp = new node;
temp->data = value;
temp->link = NULL;
while(*test != NULL){
*test = (*test)->link;
}
*test = temp;
}
'test-> link = temp;'而不是最後一行 – d9ngle