What is a reference variable in C++?

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

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

12条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 09:17

    A reference is an entity that is an alias for another object.

    A reference is not a variable as a variable is only introduced by the declaration of an object. An object is a region of storage and, in C++, references do not (necessarily) take up any storage.

    As objects and references are distinct groups of entities in C++ so the term "reference variable" isn't meaningful.

提交回复
热议问题