I came across some C++ code of the form below, where Foo is an object:
Foo y;
[...]
const Foo & x = y;
I haven’t seen this usage of & before. What search terms can I use to learn about this usage of &?
>Solution :
const Foo & and const& Foo are all the same.
They declare that x is a const reference to y. Operations called on x will be called on y, but x can only access const operations.
(Though there are some syntactical quirks that can arise if Foo is a pointer)