小杨想在如上题所述的双向链表中加入一首新歌曲。为了能快速找到该歌曲,他将其作为链表的第一首歌曲,则下面横线上应填入的代码为( )。
void insert(dl_node *head, string my_song) {
p = new dl_node;
p->song = my_song;
p->prev = nullptr;
p->next = head;
if (head != nullptr) {
______________// 在此处填入代码
}
head = p;
}
head->next->prev = p;
head->next = p;
head->prev = p;
触发异常,不能对空指针进行操作。