Re: weird /strange???
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Wed, 15 Mar 2006 08:27:14 -0800
One more thing:
Why would you do (true && b1)? Wouldn't that be the same as
b = b1 since "true" would always be a positive result? You don't really
"need" to compare it to "true".
Tom
bool b,b1;
b1 = MyData.success;
//MyData is protected using Mutex, b1=true here by using Visual Studio
watch window
b = (b1 == true);//return false ??????
b = (true && b1);//return true
"Tim Slattery" <Slattery_T@xxxxxxx> wrote in message
news:g56g12ts8qu4o0lvo4m4rd0rpubaelu5kg@xxxxxxxxxx
"Heinz Ozwirk" <hozwirk.SPAM@xxxxxxxx> wrote:
"kathy" <yqin_99@xxxxxxxxx> schrieb im Newsbeitrag
news:1142359707.474751.38170@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a piece of code which is in a multithread program:
...
bool b,b1;
b1 = MyData.success;
//MyData is protected using Mutex, b1=true here by using Visual Studio
watch window
b = (b1 == true);//return false ??????
b = (true && b1);//return true
...
Never compare a boolean value with true, always compare with false.
Why in the world?!?!?
Even though bool is basically defined as enum { false, true } it is large
enough to hold other values than 0 and 1.
No. The older Windows typedef BOOL is a redefinition of an integer,
and many different values could be stored there. The C++ primitive
datatype "bool", on the other hand, can store only the constants true
or false.
--
Tim Slattery
MS MVP(DTS)
Slattery_T@xxxxxxx
.
- References:
- weird /strange???
- From: kathy
- Re: weird /strange???
- From: Heinz Ozwirk
- Re: weird /strange???
- From: Tim Slattery
- weird /strange???
- Prev by Date: Re: speech balloons at system tray icons
- Next by Date: Re: Toolbar strange behaviour
- Previous by thread: Re: weird /strange???
- Next by thread: Re: weird /strange???
- Index(es):
Relevant Pages
|