|
But of course that only pertains to the Microsoft BOOL variable and not bool in C++. C did not actually have a bool value defined until C99. BOOL is actually an INT (sizeof(BOOL) = 4 or 8 on x64) whereas bool is a byte (sizeof(bool) = 1). Most languages use a built in type of bool that is one byte and only capable of being true or false (1 or 0). The proper use of BOOL is to test if it is non-zero for TRUE with most functions that return BOOL. Some functions that return BOOL will actually return more than just 2 possible answers (ie: 0 for success or a value representing a return or error code).
|
|
|
|
|
Then it depends on the language?
|
|
|
|
|
|
if(statement is true)
{
return "Yes";
}
else if(statement is false)
{
return "No";
}
else
{
return "The meaning of life";
}
In what school this philosophy lies?
Ittay Ophir
ittay.ophir@gmail.com
|
|
|
|
|
Don't know, but I can tell you that if you ever find your function returning "the meaning of life" then something has gone horribly horribly wrong. :-/
|
|
|
|
|
A decent compiler would issue a diagnostic for that final else clause.
Software Zen: delete this;
|
|
|
|
|
return 42;
This would be it I think.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
|
There are two else s and at least one if to nuke.
|
|
|
|
|
That's fuzzy logic and would mean that "statement" could not be a boolean variable having only two states. An example would be if you were testing to see if a string was equal to something. An exact match would be true and a partial match would be not false or true and a complete miss would be false.
Statement = "My dog has fleas"
if( Statement = "dog" )
else if( Statement contains "dog" case insensitively)
else
|
|
|
|
|
Behind every seemingly trivial task there are many schools of philosophy
Marcello Turnbull
|
|
|
|
|
It means people have too much free time.
|
|
|
|
|
How much free-time do you have?
|
|
|
|
|
A little time for suggesting a survey but so much time for answering a question
Cheers
Marcello Turnbull
|
|
|
|
|
if somthingIsTrue()
do this
else
do that
-------------------- and not -----------------------
if NOT somethingIsTrue()
do something
ELSE
do something else
if it is true
forsooth!
|
|
|
|
|
Well
If NOT IsEOF
keep reading
else
clean up and close file, etc
|
|
|
|
|
If there is code under both true and false conditions then I put the true block first, otherwise it's dependent...so I need to select two choices...
|
|
|
|
|
the normal case (and that better be the positive one) first, unless the normal case extends over more than a screen full or a page full AND the special case is extremely short.
BTW: I tried not to ask nor elicit a question, it says "Please DO NOT POST PROGRAMMING QUESTIONS HERE."
|
|
|
|
|
on what's the common/expected/preferred case (postponing all error handling as long as possible )
|
|
|
|
|
The survey is paramount to the following code:
bool a;
if(!a)
{
a = false;
}
elseif(a)
{
a = true;
}
If at first you don't succeed, failure may be your style. (Quentin Crisp)
Recession is when a neighbor loses his job. Depression is when you lose yours. (Ronald Reagan)
modified on Monday, January 19, 2009 2:00 AM
|
|
|
|
|
if (statement is true)
{
Label.Text="1";
}
|
|
|
|
|
"Behind every seamingly trival task there are vast schools of philosophy."
Maybe so. But I think the survey's description should read:
"Behind every seemingly trival task there are vastly different schools of thought."
/ravi
|
|
|
|
|
That all depends on one's philosophy doesn't it?
Subvert The Dominant Paradigm
-- bumper sticker, circa 1971
|
|
|
|
|
More like one's grammar, actually.
/ravi
|
|
|
|
|
Philosophy doesn't imply thought. There is the philosophy of, "that's how I was told to do it".
|
|
|
|