int median(const my_array& a);
- The argument is passed as a reference, so the function receives a copy that can be modified without affecting the original value.
- The argument is passed as a reference, so if the passed my_array object is large, the program will require less time and memory.
- Actually objects can’t be passed as regular variables because they require a constructor call. Therefore a const reference is the only way to pass class instances to functions.
- There are no benefits because a reference and an object are treated as the same thing.
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.