bool a; //no initialized
if(a == true)
{
//do 1
}
if(a == false)
{
//do 2
}
Result is not 'do 1' nor 'do 2'.'a' is not initialized. 'a' is not 'true' nor 'false'.This is contrary to the definition of 'bool' logic.'bool' variable is either 'true' or 'false'.Can not have the other values.According to the interpretation of a friend before.'true' should be a logical value, rather than an actual value.That is 'true' should be '! false', rather than the other what the exact value.But that there is no way to express in a programming language.We can refer to a lot about bool definition.
in VS "windef.h"
typedef int BOOL;
#define FALSE 0
#define TRUE 1
in SDL
typedef enum
{
SDL_FALSE = 0,
SDL_TRUE = 1
}SDL_bool;
People trying to use an exact value represents the 'true', But this logic is wrong.So I think that should be realized through the state variables to solve this problem.the method I mentioned before.
For example:
bool a = 2;
if(a)
{
//do true
}
if(!a)
{
//do false
}
the result is 'do true'.It is correct from logical?