Well, I had this problem, and I could not find a good answer, so I'm going to share what I found out.
You can go by value, there is nothing wrong with that. (as you showed in your question.)
But the reason we pass the parameter through the const link is because the function does not create an actual copy of the called value. Its reference, therefore, it simply points to this value, wherever it is in memory.
This saves processing time, especially if it is something big, having thousands of names ... In this case, the saved time will be almost nothing.
And for a constant that guarantees the user the function that the reference value will not be changed, because it can be changed, since you have access to the original location in memory, because it is passed by reference .. If your function definition actually changes the parameter value called in the const link, this will be a compiler error, this will not allow you to do this. because when you put const, you tell the compiler that this value cannot be changed.
3366784
source share