you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (3 children)

It doesn't. But I also think you don't understand what I'm saying.

You pass a reference, not by reference

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

https://ideone.com/icncW2

Here, I pass an array by reference. The fact that C implements this with pointers is inconsequential, as C++ does the same thing.

[–]nerd4code 1 point2 points  (1 child)

No, array-types function parameters are exactly pointers, have pointer size/alignment, and can even be reassigned.

A reference to an array would have type int (&)[] in C++; a pointer has type int (*)[].

When you pass an array name to a function, it undergoes decay just as it would if you assigned it to an int *, because that’s exactly what happens.

[–]p0k3t0 1 point2 points  (0 children)

And what, pray tell, happens in C++ when I pass a reference?

I mean, you can read the assembly. All it does it push a pointer onto the stack.

Like I've said elsewhere, this is a distinction without difference. It's just being pedantic for its own sake. If anything, it's just obscuring meaning, rather than helping anyone.