What does this mean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What does this mean?

int &y = x;

5th Jan 2019, 6:05 AM
Anjali Kesavarapu
2 Answers
+ 9
It declares and initializes a reference (alias) called `y` for `x`. In other words, `y` holds the same value as `x` and altering `y` affects `x`, as well. #include <iostream> int main() { int x = 10; int &y = x; ++y; std::cout << x; // 11 } _____ https://en.cppreference.com/w/cpp/language/reference https://en.cppreference.com/w/cpp/language/reference_initialization
5th Jan 2019, 6:26 AM
Babak
Babak - avatar
+ 3
Thanq..
5th Jan 2019, 9:20 AM
Anjali Kesavarapu