c++ - *& 用于参数时是什么意思?

标签 c++ pointers parameters reference arguments

我想知道 *& 是什么意思。 上下文:

一个函数实现如下:

void headInsert( Node*& head, int info )
{
    Node* temp = new Node(info);
    temp->link = head;
    head = temp;
}

为什么不只使用 Node& 呢?

谢谢

最佳答案

Node*& 表示“对指向 Node 的指针的引用”,而 Node& 表示“对 Node 的引用”。

Why not just use Node& ?

因为 headInsert 函数需要改变 head 指向的地方。

关于c++ - *& 用于参数时是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27529522/

相关文章:

c++ - 使用 COM 搜索 Outlook 联系人?

c++ - 将属性表制作为 MDI 子项

c - 理解字符串数组 C

javascript - 调用 Javascript 函数后的括号是做什么用的?

sql - "Order By"使用参数作为列名

c++ - std::set 删除复杂性异常?

c++ - 如何编译并运行一个hello world JUCE程序?

c - 在函数中重新分配后出现段错误

c - 当我想保护 vector 的修改时,如果我尝试使用它,为什么 const 子句不起作用?

javascript - 如何动态地将参数从高阶函数传递到回调函数?