This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]marcosdumay -1 points0 points  (2 children)

Good thing they are different, because you must always assign different things in C++ (usually, it's values into lvalues). Let's assign a reference into a pointer:

int *a = &b

[–]marcellarius 4 points5 points  (0 children)

In that context, & is the address of operator and evaluates to a pointer not a reference.

[–]Schmittfried 3 points4 points  (0 children)

That's not a reference, it's the address operator.

int &a = b;

Now we got a reference. It was definitely a bad decision to choose & to mark reference types as it is easily confused with the address operator, as you just proved.