2 ms·
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, y
by TheCoelacanth 9y 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.
- chi3 9y agoBut 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.