Skip to main content
C++

References in C++

By January 21, 2020May 1st, 2020No Comments

Definition:

A reference variable is a “reference” to another variable. Better definition: A reference variable is just another pointer variable which will take its own space in memory from here References are nothing but constant pointers in C++. A statement int &i = j; will be converted by the compiler to int *const i = &j . Again from here

Usage:

Declare a reference as such with the “&”:
When you change the value of the reference variable you also change the value of the original variable. For example

Leave a Reply