What is a reference variable in C++?

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

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

12条回答
  •  温柔的废话
    2020-11-22 09:14

    Reference variables (let a), just say for easy understanding, another name of variable (let x), which holds the same exact memory location as that of x.

    int &a = x; refers that a holds same memory location as that of x.

    For example, say two roommates share the same room. One friends name is x and another friends name is a. If a changes the location of the table placed in the room, from position (x,y,z) to (x1,y1,z1) then changes are visible to friend x as well and vice versa.

提交回复
热议问题