Hacker News new | ask | show | jobs
by TheCoelacanth 2977 days ago
In C++, terms

    void f(Foo x); // pass-by-value
    void f(Foo* x); // pass-pointer-by-value
    void f(Foo& x); // pass-by-reference
In the last example, you aren't passing in a value, you are essentially creating an alias for some variable in the calling scope.
1 comments

But it's still just a pointer underneath? It's more or less just syntactical sugar which makes it dereferenced it for you, and I'd argue that it only makes sense to use the phrase in certain contexts.

The only real difference between the last two is that the last one shouldn't be sent in as null, isn't it? The test in OPs artictle doesn't really make sense either, because you can switch the values using pointers as well.