×

C++ Programs

C++ Most popular & Searched Programs

C++ Basic I/O Programs

C++ Constructor & Destructor Programs

C++ Manipulators Programs

C++ Inheritance Programs

C++ Operator Overloading Programs

C++ File Handling Programs

C++ Bit Manipulation Programs

C++ Classes & Object Programs

C++ program to demonstrate use of reference variable

Learn about the reference variables in C++, how to declare and use them in our C++ program?
[Last updated : March 01, 2023]

C++ Reference Variables

Reference variable is the important and new concept in C++ programming language, the reference variables are used as a reference of existing variables i.e., reference variables are the alternative names of the existing variables.

In this program you will learn how to use reference variable in c++ programming language to make an alias of a variable.

Reference variable example in C++

/*C++ program to demonstrate use of reference variable.*/
#include <iostream>
using namespace std;
 
int main()
{
    int a=10;
 
    /*reference variable is alias of other variable, 
    It does not take space in memory*/
 
    int &b = a; 
 
    cout << endl << "Value of a: " << a;
    cout << endl << "Value of b: " << b << endl;
 
    return 0;
}

Output

Value of a: 10
Value of b: 10

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.