Left value

Jan 18, 2014 at 2:27pm
Hello!
Please, it says in a book:
"left value is everythnig that can be used to initioalise a reference."

Please, what is exactly a reference?
many thanks!!

Jan 18, 2014 at 4:22pm
see this code:
1
2
3
4
5
6
7
8
int x=3;
int &y=x;
cout<<"&x="<<&x<<endl;
cout<<"&y="<<&y<<endl;
x=5;
cout<<"y="<<y<<endl;
y=3;
cout<<"x="<<x;

the output is:
&x=AAAAAAAA
&y=AAAAAAAA
y=5
x=3

here y is a reference to x
as you can see here when you changed x, y also changed and vice-versa that's because y became x (the same address as you can see also in the first two lines)
Jan 18, 2014 at 7:20pm
Hello!, JewelCpp!!!
It says here, left value is everything in the memory space that can have an address.

But

we INITIALISE with a right value, not the left one, don't we?

So, the better definition of a left value is that it CAN HAVE AN ADDRESS, isn't it?

int& a=b;

b is also a left value cause it can have an adress.

So, we DO NOT INITIALISE WITH LEFT VALUE, but, left value is all that CAN BE INITIALISED by anything.

Did I understand it properly?

Many thanks!!!
Jan 21, 2014 at 8:18pm
Sorry I'm late what I did is that I answered your question
Please, what is exactly a reference?
as best as I could (and know)
I didn't tri to correct the book or anything
Topic archived. No new replies allowed.