never mind, I looked it up. It’s a “reference” instead of a pointer. Similar, but unlike a pointer it doesn’t create a distinct variable in memory of its own.
I’m almost sure it does create a distinct variable in memory. Internally it’s still a pointer, specifically a const pointer (not to be confused with a pointer to a const value; it’s the address that does not change). Think about it as a pointer that is only ever dereferenced and never used as a pointer. So yes, like the other commenter said, like an alias.
I don’t think references are variables: you can’t modify them, and AFAIR you can’t have pointers to them, with the possible but unlikely exception of non-static member references.
An int& reference is just as much of a variable as int* const would be (a const pointer to a non-const int). “Variable” might be a misnomer here, but it takes just as much memory as any other pointer.
I’m almost sure it does create a distinct variable in memory. Internally it’s still a pointer, specifically a const pointer (not to be confused with a pointer to a const value; it’s the address that does not change). Think about it as a pointer that is only ever dereferenced and never used as a pointer. So yes, like the other commenter said, like an alias.
I don’t think references are variables: you can’t modify them, and AFAIR you can’t have pointers to them, with the possible but unlikely exception of non-static member references.
An
int&
reference is just as much of a variable asint* const
would be (a const pointer to a non-const int). “Variable” might be a misnomer here, but it takes just as much memory as any other pointer.