Good Morning,
I just have a quick question about good programming practice with parameter arguments in C++.
Is it good programming practice to const all parameter arguments that will not be changed internally? For example.
void Agent::setHealth( const int h ){
health = h;
}
However, if I have the same function, but this time wish to signify to users that the parameter value might not be what's assigned to a private/protected variable inside the class I could do something like this
void Agent::setHealth( int h ){
health = glm::clamp( h , 0 , INT_MAX );
}
I am also talking about primitive types available through C++ not const referenced variables passed as arguments.
Is it a waste of time to 'const' and just use the variable with function documentation?
Thanks so much for the time,
Mike