Here's my function definition
1 2
|
bool validateNumber(string& text, int min = 0, int max = -1, bool useMin = true,
bool getValid = true)
|
The code takes the string text, and checks the make sure that the input is valid and safe to convert and use as a number. However, sometimes there is not min, and sometimes there is no max. The lack of min is done by using the parameter useMin, while the lack of max is done by max < min.
My predicament is the following call:
validateNumber(text, -2);
Now, max will be used, even though I don't want it. Ideally, I would want to do something like
... int max = (min - 1), ...
but that doesn't work. I also can't check to see if the parameter hasn't been changed (that I know of), because the following call would make it look like it hasn't
validateNumber(text, -2, -1);
So the question is, is there a way to do what I want, without having to add in a
bool useMax
parameter? Or is this my only option? I don't want to do that for simplicity, but if I have to, I have to.
Thanks.