1

What are references in C++?

Vishalini.R Answered question June 27, 2023
User Avatar

When a variable is described as a reference it becomes an alias of the already existing variable. In simple terms, a referenced variable is another named variable of an existing variable keeping in mind that changes made in the reference variable will be reflected in the already existing variable. A reference variable is preceded with a ‘&’ symbol.

Syntax:

int GFG = 10;

// reference variable
int& ref = GFG;
For more information, refer to references in C++