I can think of a few reasons:
1) When someone reads the code and see const T a
, they know that a
should not be modified in the body of the function.
2) The compiler will tell you when you try to modify a
in the body of the function. Therefore, adding const
can prevent mistakes.
BTW chris already mentioned this in the comments.
3) However, there is another difference in C++11. A constant object cannot be moved from, as a move operation modifies the object. Therefore, you can only make a copy of a
in the function body and cannot move from it.
4) Also, if this is a class type, you cannot call non-const members functions on a const object.