This question already has an answer here:
If I have
int x = 25;
int& y = x;
I understand that x and y point to the same memory location. However, when I have:
int x = 25;
int&& y = x;
I get:
error: expected unqualified-id before '&&' token
What is the explanation in terms of lvalue and rvalue? I cannot wrap my head around the concept and how it is applied here.
Also, is it true that if you want to reference a number, you should only be able to do it using something like const int& z = 25
and never int& z = 25
because of the reason that you are referencing a number and numbers don't change?
Aucun commentaire:
Enregistrer un commentaire