C++ Program to demonstrate usage of reference types
Program
#include<iostream>
using namespace std;
int main()
{
int a = 10;
int &b = a;
cout << "Value of a:\t" << a << endl;
cout << "Value of b:\t" << b << endl;
a++;
cout << "After change" << endl;
cout << "Value of a:\t" << a << endl;
cout << "Value of b:\t" << b << endl;
}
Output
Value of a: 10
Value of b: 10
After change
Value of a: 11
Value of b: 11