1. You are guaranteed that the parameter is not NULL.
2. It gives you a simplified syntax for accessing what is essentially a pointer under the hood.
3. The original value can be updated and passed around, allowing a called function to update the source value.
When you pass by value, you're creating a copy and any changes made will only operate upon the copy.
Whether or not you pass by reference is determined by whether or not you need to update the source value. And possibly also if the value is a large block of data, passing by reference only consumes 4 bytes of stack space for 32-bit, or 8 bytes for 64-bit, and is more conducive to performance.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.