What does '&' mean in C++?

后端 未结 11 1602
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 02:20

What does \'&\' mean in C++?

As within the function

void Read_wav::read_wav(const string &filename)
{

}

And what is its equiv

11条回答
  •  孤街浪徒
    2021-01-18 02:59

    In this case, string &filename means the function will receive a reference (a memory address) as a parameter, instead of receiving it as a copy.

    The advantage of this method is that your function will not allocate more space on the stack to save the data contained in filename.

提交回复
热议问题