The const method prototype enables you to use such method also for const objects like:
struct X
{
void function_name(std::string& txt) const {}
};
int main()
{
const X x;
std::string s{"Hallo"};
x.function_name(s); // will not work if the function is not marked as const!
}
The second case
void function_name(const int a);
gives the compiler a hint that you will ( and can ) never change the content of the const variable. That allows the compiler to optimize it. If you use a non trivial object like:
void function_name(const XYZ x);
it makes more sense, because if it is not const, the compiler must create a full copy of the object for that function. That may also be optimized out, but in case of const there is simply no need to take a copy as nothing will be altered. By standard clever compilers the internal generated code can be equivalent to:
void function_name(const XYZ& x);
or
void function_name(XYZ& x);
For the given example of using an int, it is has more or less no effect, but clarifies the interface.