0x777C
0x777C

Reputation: 1047

What happens if I get the reference of a variable passed with an ampersand?

Ok so lets say I have function(int& myval), if in the body of that function I do &myval will that point to the parameter on the stack or the original value?

Upvotes: 0

Views: 132

Answers (2)

Mauro Dorni
Mauro Dorni

Reputation: 487

As said by Sombrero Chicken, a reference doesn't have an address: consider it like an "alias" of the referenced variable, just another name to reference it ( nomen omen)

Upvotes: 0

Hatted Rooster
Hatted Rooster

Reputation: 36483

References don't have an address, using the address-of operator & on a reference type will return the address of the variable that the reference is bound to.

Upvotes: 5

Related Questions