I'm pretty new to C++ and I cannot seem to grasp why we would use a referee to a variable instead of just using the variable itself.
#include <iostream>
int main()
{
using namespace std;
int ival = 1024;
int &refVal = ival;
cout << ival << endl << refVal << ends;
return 0;
}
What is the point of the reference if it only ever gives the value of ival? Why not just use ival?