如何在C ++中实现bool数据类型 [英] How bool data type is implemented in C++

查看:81
本文介绍了如何在C ++中实现bool数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

有人可以对bool数据的实现有所了解吗?在C ++中使用
类型?我听说它是​​基于位的,但是想确认这个信息是否为
。有没有我可以查看的源代码?


~谢谢,

Ramesh。

Hi all,
Can someone throw some light on the implemetation of bool data
type in C++? I have heard that it is bit based, but want to confirm
this information. Is there any source code where I can look into?

~Thanks,
Ramesh.

推荐答案

8月22日下午3:34,a2z< ramesh.hem ... @ gmail.comwrote:
On Aug 22, 3:34 pm, a2z <ramesh.hem...@gmail.comwrote:

大家好,

有人可以对bool数据的实现有所了解吗?在C ++中使用
类型?我听说它是​​基于位的,但是想确认这个信息是否为
。有没有我可以查看的源代码?


~谢谢,

Ramesh。
Hi all,
Can someone throw some light on the implemetation of bool data
type in C++? I have heard that it is bit based, but want to confirm
this information. Is there any source code where I can look into?

~Thanks,
Ramesh.



不受c ++标准的约束。 sizeof(bool)也是实现

定义的。鉴于此,实现可以自由地用bit-

表示,作为char,或者甚至作为int,或者任何其他方式来表示它们,因为它们是b $ b b希望的。 />

-N

Not dictated by the c++ standard. sizeof(bool) is also implementation
defined. Given that, implemenations are free to represent them in bit-
representation, as a char, or even as an int, or any other way as they
wish.

-N


Neelesh Bodas写道:
Neelesh Bodas wrote:

8月22日下午3:34,a2z< ramesh.hem ... @ gmail.comwrote:
On Aug 22, 3:34 pm, a2z <ramesh.hem...@gmail.comwrote:

>大家好,
可以有人对C ++中bool
数据类型的实现有所了解吗?我听说它有点基础,但是想要确认这些信息。有什么源代码可供我查看吗?

〜谢谢,
Ramesh。
>Hi all,
Can someone throw some light on the implemetation of bool
data type in C++? I have heard that it is bit based, but want to
confirm this information. Is there any source code where I can look
into?

~Thanks,
Ramesh.



不受c ++标准的约束。 sizeof(bool)也是实现

定义的。鉴于此,实现可以自由地表示它们作为一个字符,或者作为一个整数,或者任何其他方式,因为它们是b $ b b表示。


Not dictated by the c++ standard. sizeof(bool) is also implementation
defined. Given that, implemenations are free to represent them in bit-
representation, as a char, or even as an int, or any other way as they
wish.



不确定你的意思是位代表。每个对象(即使是
类型''bool'')都必须有自己的地址,所以sizeof(bool)不能比
少,所以char是表示bool值的最小单位。如果我理解错误,请

详细说明。


V

-

请删除资金''A'在通过电子邮件回复时

我没有回复最热门的回复,请不要问

Not sure what you mean by "bit-representation". Every object (even of
type ''bool'') has to have its own address, so sizeof(bool) cannot be less
than 1, so a char is a minimal unit to represent a bool value. Please
elaborate if I understood you incorrectly.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


8月22日下午4:43,Victor Bazarov < v.Abaza ... @ comAcast.netwrote:
On Aug 22, 4:43 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:

Neelesh Bodas写道:
Neelesh Bodas wrote:

On 8月22日下午3:34,a2z< ramesh.hem ... @ gmail.comwrote:
On Aug 22, 3:34 pm, a2z <ramesh.hem...@gmail.comwrote:

大家好,

可以有人对C ++中的bool

数据类型的实现有所了解吗?我听说它有点基础,但是想要确认这些信息。
确认这些信息。有什么源代码我可以看看

进去吗?
Hi all,
Can someone throw some light on the implemetation of bool
data type in C++? I have heard that it is bit based, but want to
confirm this information. Is there any source code where I can look
into?


~谢谢,

Ramesh。
~Thanks,
Ramesh.


不受c ++标准的规定。 sizeof(bool)也是实现

定义的。鉴于此,实现可以自由地表示它们作为一个字符,或者作为一个整数,或者任何其他方式,因为它们是b $ b b表示。
Not dictated by the c++ standard. sizeof(bool) is also implementation
defined. Given that, implemenations are free to represent them in bit-
representation, as a char, or even as an int, or any other way as they
wish.



不确定你的意思是位代表。每个对象(即使是
类型''bool'')都必须有自己的地址,所以sizeof(bool)不能比
少,所以char是表示bool值的最小单位。如果我不正确地理解你,请详细说明


Not sure what you mean by "bit-representation". Every object (even of
type ''bool'') has to have its own address, so sizeof(bool) cannot be less
than 1, so a char is a minimal unit to represent a bool value. Please
elaborate if I understood you incorrectly.



可能我使用了不正确的terminlogy。通过比特表示我提到了与基于位相关的OP所指的相同的东西。在其他

字中,有些东西可能是真和假可能是任何特定的位序列(比如24位= 3字节)并在任何

方式 - true是备用的'和'零',false是全零。


-N

Probably I used incorrect terminlogy. By "bit-representation" I was
mentioning the same thing that OP meant by "bit based". In other
words, something to the effect that true and false might be any
specific sequence of bits (say 24 bits = 3 bytes) and defined in any
manner - true is alternate one''s and zero''s and false is all zeros.

-N

这篇关于如何在C ++中实现bool数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆