问题描述
我正在实现链接列表的实现,该列表在以下网站上提供:
https://www.bitdegree.org/learn/linked-list-c-plus-plus
我想知道为什么他们在push函数中传递参数struct Node ** head_ref
,如果我没记错的话,它是对引用的引用:
void push(struct Node ** head_ref,int new_data) {
struct Node * new_node = (struct Node * ) malloc(sizeof(struct Node));
new_node->data = new_data;
new_node->next = ( * head_ref);
( * head_ref) = new_node;
}
它们还为新节点分配内存:
struct Node * new_node = (struct Node * ) malloc(sizeof(struct Node));
我们可以用Node * new_node = new Node(sizeof(Node))
替换此行吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)