Passing by const reference can be benefitial if the object is large (like if it's a class) since it doesn't require the object to be copied.
There isn't much/any point to passing an int by const reference, and in fact it's probably worse performance-wise. I think newbies just get it in their head that "pass by reference is faster" and then they start to pass everything by reference when you really shouldn't.
Why would you ever use const
Passing by const reference instead of by non-const reference allows the compiler to make optimizations. It also makes your code more clear -- that is you can give this function a reference to your object and rest in comfort knowing that your object won't be changed. Whereas if the reference were non-const, it might be changed, and so you might have to yutz around making a backup copy of your object to make sure the original data isn't lost.
Just to be thorough... if you are going to use reference parameters then you absolutely must be sure to use const correctly. The following code does NOT compile on a compliant compiler:
1 2 3 4 5 6 7 8 9
#include <string>
void foo( std::string& s ) {
std::cout << s;
}
int main() {
foo( "Hello World!" );
}
but DOES compile and work correctly if you change foo's parameter to a const reference. This is because of the rule that temporaries cannot bind to non-const references. In the above case, the compiler wants to create a temporary string object out of "Hello World!" and pass the temporary to foo. But foo takes a non-const reference, so the compiler can't do that. Result: compile error.
You should learn const correctness either before learning references or at the same time.