Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   What is a boolean data type? (http://www.velocityreviews.com/forums/t458752-what-is-a-boolean-data-type.html)

Pep 11-28-2006 12:20 PM

What is a boolean data type?
 
This is getting weird. I have to keep moving between visual c and gnu
c++ compilers and now have come across a problem that seems to relate
to the boolean datatype.

I have a method that is defined as

boolean isOkay(string var)
{
... some code ...

return(true);
}

But this seems to not be working properly.

So I did a quick investigation of the boolean adta type and can find
nothing for it. I can find the following

bool = original C
Boolean = C++
BOOLEAN = not sure

So what is boolean and why does it now work the same as bool, or
Boolean or BOOLEAN?

TIA,
Pep.


Jacek Dziedzic 11-28-2006 12:39 PM

Re: What is a boolean data type?
 
Pep wrote:
> This is getting weird. I have to keep moving between visual c and gnu
> c++ compilers and now have come across a problem that seems to relate
> to the boolean datatype.
>
> I have a method that is defined as
>
> boolean isOkay(string var)
> {
> ... some code ...
>
> return(true);
> }
>
> But this seems to not be working properly.
>
> So I did a quick investigation of the boolean adta type and can find
> nothing for it. I can find the following
>
> bool = original C
> Boolean = C++
> BOOLEAN = not sure


I would disagree with all three. AFAIK C has no bool type,
the C++ type is 'bool' and Microsoft's type is 'BOOL'.

> So what is boolean and why does it now work the same as bool, or
> Boolean or BOOLEAN?


Stick to bool, that's the standard C++ type.

HTH,
- J.

linuke@gmail.com 11-28-2006 12:42 PM

Re: What is a boolean data type?
 
bool
This keyword is a built-in types in the standard c++, (should be true
or false)

BOOLEAN
Boolean variable (should be TRUE or FALSE).
This type is declared in WinNT.h as follows:
typedef BYTE BOOLEAN;


Pep 11-28-2006 12:54 PM

Re: What is a boolean data type?
 

linuke@gmail.com wrote:
> bool
> This keyword is a built-in types in the standard c++, (should be true
> or false)
>
> BOOLEAN
> Boolean variable (should be TRUE or FALSE).
> This type is declared in WinNT.h as follows:
> typedef BYTE BOOLEAN;


Thanks to everyone, as suspected I'll stick to the c++ type.

Incidentally it turns out the boolean type is working correctly, the
problem with the code is further down the source deck, go figure :)

Cheers,
Pep.


Ron Natalie 11-28-2006 12:54 PM

Re: What is a boolean data type?
 
linuke@gmail.com wrote:
> bool
> This keyword is a built-in types in the standard c++, (should be true
> or false)
>
> BOOLEAN
> Boolean variable (should be TRUE or FALSE).
> This type is declared in WinNT.h as follows:
> typedef BYTE BOOLEAN;
>


Which in fact, is not a boolean. It's a char which
has the old C behavior of zero for false, anything else
for true.


Frederick Gotham 11-28-2006 05:50 PM

Re: What is a boolean data type?
 
Pep:

> boolean isOkay(string var)



If I'm not mistaken, the type in question is called "boolean" in Java, and
"bool" in C++.

There's no such things as "boolean", "BOOLEAN" or "BOOL" in Standard C++.

--

Frederick Gotham

Clark S. Cox III 11-28-2006 08:42 PM

Re: What is a boolean data type?
 
Jacek Dziedzic wrote:
> Pep wrote:
>> This is getting weird. I have to keep moving between visual c and gnu
>> c++ compilers and now have come across a problem that seems to relate
>> to the boolean datatype.
>>
>> I have a method that is defined as
>>
>> boolean isOkay(string var)
>> {
>> ... some code ...
>>
>> return(true);
>> }
>>
>> But this seems to not be working properly.
>>
>> So I did a quick investigation of the boolean adta type and can find
>> nothing for it. I can find the following
>>
>> bool = original C
>> Boolean = C++
>> BOOLEAN = not sure

>
> I would disagree with all three. AFAIK C has no bool type,


<OT>
FYI: As of C99, C does have a built in boolean type, it's called
"_Bool", or after you include <stdbool.h>, "bool" (i.e. same name as in
C++).
</OT>

--
Clark S. Cox III
clarkcox3@gmail.com

Jacek Dziedzic 11-30-2006 01:31 PM

Re: What is a boolean data type?
 
Clark S. Cox III wrote:
> Jacek Dziedzic wrote:
>> Pep wrote:
>>> This is getting weird. I have to keep moving between visual c and gnu
>>> c++ compilers and now have come across a problem that seems to relate
>>> to the boolean datatype.
>>>
>>> I have a method that is defined as
>>>
>>> boolean isOkay(string var)
>>> {
>>> ... some code ...
>>>
>>> return(true);
>>> }
>>>
>>> But this seems to not be working properly.
>>>
>>> So I did a quick investigation of the boolean adta type and can find
>>> nothing for it. I can find the following
>>>
>>> bool = original C
>>> Boolean = C++
>>> BOOLEAN = not sure

>> I would disagree with all three. AFAIK C has no bool type,

>
> <OT>
> FYI: As of C99, C does have a built in boolean type, it's called
> "_Bool", or after you include <stdbool.h>, "bool" (i.e. same name as in
> C++).
> </OT>


Thanks, I forgot C keeps evolving. :)

- J.


All times are GMT. The time now is 07:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.