I’m redesigning a class constructor in C++ and need it to catch an unspecified bool. I have used default values for all of the other parameters, but from my understanding bool can only be initialized to true or false. Since both of those cases have meaning in the class, how should I handle checking for change from a default value?
Share
The reality is that you can’t do this. A bool has value, either true or false, and if you haven’t initialized it then it is randomly true or false, possibly different at each run of the program or allocation of that class.
If you need to have a type with more options, define an enum.