bool
how to make bool var which is 1 be 0 after adding with 1???
1 2 3 4 5 6 7 8
|
#include <iostream>
using namespace std;
int main(){
bool test=1;
test+=1;
cout<<test;
return 0;
}
|
Are you sure you want to use bool?
If you want to make it go from true to false have you considered assigning it false (0) instead of trying to make 2 false.
1 2 3 4 5 6 7 8 9 10 11 12
|
//flip the sign
if(test)
{
test = false;
}
else
{
test = true;
}
//or
test = test ? false : true;
|
You could use a
char
instead of
bool
.
1 2 3 4 5 6 7 8 9 10 11 12
|
#define BOOL unsigned char;
#define TRUE 1;
#define FALSE 0;
#define IS_TRUE(a) (((a) & 0x1) == 1)
BOOL test = TRUE;
test += TRUE;
if ( IS_TRUE(test) )
{
// do something
}
|
Last edited on
Topic archived. No new replies allowed.