creasso
(creasso)
February 18, 2015, 12:40am
1
Hi.
Got a crazy C++ “bug?” today and would like to get some feedback…
The issue:
[FONT=Courier New]
bool bMyBool = false;
while(bWhatever)
{
if(bMyBool) // <- This is considered "valid" regardless the inner value and breaks
break;
}
while(bWhatever)
{
if(bMyBool == true) //<- This keeps the loop til I assign true somewhere.
break;
}
On all my remaining code I could use if(Boolean) and if(!Boolean), so I’m almost sure it’s not syntax.
Any explanation? LOL
marotili
(marotili)
February 18, 2015, 3:15am
2
Please provide a full source example. Where is bWhatever defined?
creasso
(creasso)
February 18, 2015, 10:24pm
3
I set the values on the object Constructor, they’re declared on .h
.h
bool bWhatever;
bool bMyBool;
On construct (cpp)
Object::Object()
{
bWhatever = true;
bMyBool = false;
}
uint32 Object::Run(void)
{
while(bWhatever)
{
if(bMyBool == true) //<- This is the way I got to work, if(bMyBool) ignores the bMyBool value
{
break;
}
}
return 0;
}
void Object::Stop(void)
{
bWhatever = false;
bMyBool = true; // Stop this “NOW”!!!
}