int median(const my_array& a)
- Actually, objects cannot 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.
- The const qualifier Forbids the code to modify the argument, so the programmer can rest assured that the source object will remain unchanged.
- The argument is passed as a reference, so the Function receives a copy that can be modified without affecting the original variable.
Note: This one is similar to Q6, but focuses on the const keyword.
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.