If I have this code:
void Foo(aBasicType aIn) //Where aBasicType is int, char etc.
{
//...
}
Is there any point in making it const aBasicType since it is going to be copied anyway? One of the reasons I am asking is because I have seen it in 3rd party code and was wondering if there is something I am not aware of.
It cannot hurt to declare it
constif you know that your function needs not modify its value during execution.Note that functions that change their arguments, when arguments are passed by value, should be rare.
Declaring your variable
constcan prevent you from writingif (aIn = someValue).