eg:
//The standard method
int x=10;
int &y=x;
I tried
int &y;
y=x;
It didn't work, I am looking for another way to run it.
eg:
//The standard method
int x=10;
int &y=x;
I tried
int &y;
y=x;
It didn't work, I am looking for another way to run it.
You can't declare a reference without initialising it. Maybe what you want is a pointer.
There are 2 types of reference:
rvalue - refer to persistent objects whose value you want to change lvalue - refer to temporary objects whose value you want to change
lvalue Example:
int num = 1;
int& r1 {num};
int& r2; // error: need initialization
int& r2 = num;
int* p = #
int& r3 = *p;
rvalue Example:
int&& rr1{ int() }; // temporary
int&& rr2{ 2 }; // temporary