What is a reference variable in C++?

后端 未结 12 2240
孤城傲影
孤城傲影 2020-11-22 08:41

What would be a brief definition of a reference variable in C++?

12条回答
  •  一整个雨季
    2020-11-22 09:34

    It's a variable which references another one:

    int foo;
    int& bar = foo;
    

    bar is now a reference, which is to say that bar holds the location of memory where foo lies.

    See here for more information.

提交回复
热议问题