pxd2046 2022-04-09 14:51 采纳率: 100%
浏览 22
已结题

求解惑:这里符号&是什么意思?


Notification::Notification(const Notification& other)
{
    CALL_MEMBER_FN(&text, Set)(other.text.Get(), 0);
    CALL_MEMBER_FN(&status, Set)(other.status.Get(), 0);

    CALL_MEMBER_FN(&sound, Set)(other.sound.c_str());
    objectives.CopyFrom(&other.objectives);

    type = other.type;
    quest = other.quest;
    word = other.word;
    time = other.time;
}

const Notification&,这个&既不是取址也不是引用,不懂。

  • 写回答

1条回答 默认 最新

  • A-Chin 2022-04-09 15:14
    关注

    可以了解一下值传递、指针传递、引用传递,这里是引用传递,在调用Notification(const Notification& other)时,执行完该函数时,other的值按照函数里面的语句而发生改变。

    可以参考这篇博客,C/C++中的值传递,引用传递,指针传递,指针引用传递:https://www.cnblogs.com/CheeseZH/p/5163280.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
    1人已打赏

报告相同问题?

问题事件

  • 系统已结题 4月17日
  • 已采纳回答 4月9日
  • 创建了问题 4月9日