If someone told you that the following C++ function would cause the program to crash, what would you think it is that caused the problem?

It seems like we can get such a conclusion: Because the bool type parameter b of the b2s function was not initialized, the value stored in b is neither 0 nor 1, and that caused the problem.

If that interests you, change the type of b from bool to char or int and the problem will be fixed.

The C++ standard requires a bool type value to represent at least two states: true and false, but does not specify the sizeof(bool).

Related Articles