On Aug 22, 4:43 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
> Neelesh Bodas wrote:
> > On Aug 22, 3:34 pm, a2z <ramesh.hem...@gmail.com> wrote:
> >> 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.
>
> > 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.
>
> 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.
>
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