What does '&' mean in C++?

后端 未结 11 1683
隐瞒了意图╮
隐瞒了意图╮ 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 03:08

    In C, you would write it this way:

    void read_wav(struct Read_wav* , const char * pSzFileName)
    {
    
    }
    

    std::string is the C++ way of dealing with array of const char.

    & is a C++ reference. It behaves just as if you were handling the pointer behind ( its is mainly a syntactic sugar, thought it prompts the contract that the pointer behind should not be null).

提交回复
热议问题