What does '&' do in a C++ declaration?

前端 未结 7 1350
后悔当初
后悔当初 2020-11-28 03:40

I am a C guy and I\'m trying to understand some C++ code. I have the following function declaration:

int foo(const string &myname) {
  cout << \"ca         


        
7条回答
  •  無奈伤痛
    2020-11-28 04:42

    Here, & is not used as an operator. As part of function or variable declarations, & denotes a reference. The C++ FAQ Lite has a pretty nifty chapter on references.

提交回复
热议问题