I'm doing integrity checks on variables before initialising them; if they fail the checks I want them to be set to the default value. So that I don't have to edit two different sections of code (e.g. in the .h and .cpp files of a class) if I want to change the value later, is there any "set as default" function that I can call within the body of a set method?
Not exactly an urgent issue, of course, but it'd be good to know.
I was talking about the default value that can be written in the method signature.
Based on your example, in a .h file for a class I might have a method header:
void set_percentage(int newPercentage = 50);
Where 50% is the default. In your above method, therefore, is there a way to change the "else" action so that I can retrieve that value (short of recursively calling the method with no value specified, i.e. set_percentage(); )?
Basically I want to know whether that number 50 can be accessed, so that I can simply change its value the .h file without having to touch the actual implementation.