I'm looking at some source code with a large class, containing lots of getters and setters. All of the setters look generally like this:
void setIntegerVar(const int &var) {local_var = var;}
What is the motivation behind declaring the setter's argument to be an address like this? Why not just
void setIntegerVar(int var) {local_var = var;}
I assume that the answer is because the latter is not an efficient use of memory, and will be copying var
somewhere else other than where the caller is storing it. In either case, why should const
be necessary?