The point of passing by reference, I thought, was to pass in the actual variable either to save time or to modify the variable. Thus -- and this is going to make me sound stupid -- I used to think that passing a constant reference somehow temporarily changed the passed-in variable to a constant (if it wasn't already) and then changed it back to a non-constant (unless it was constant to begin with) when the function was done executing. I just learned today when I was reading C++ Primer that passing in a constant reference creates a temporary constant variable. That is,
foo(const type& obj)
is the same as
foo(const type obj)
because they both create a constant object obj
and set it equal to whatever is passed in.
So what's the point of passing by constant reference??? What's the point of references anyways? They're the same thing as pointers, except that they need to be initialized and are thus less useful.