Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Boolean

TBool represents a Boolean whose value may be ETrue or EFalse. It is implemented as a natural machine-word integer.

The C language defines logical expressions to produce 0 for false, 1 for true, and to interpret 0 as false, non-zero as true. This confusion cannot be altogether avoided with TBool. It is possible, but strongly deprecated, to assign numeric values to a TBool.

In general, a TBool should be tested using

if (x) ...

or

if (!x) ...

rather than

if (x==ETrue) ...

or

if (x==EFalse) ...

The TBool uses a whole machine word. When a class has a number of flags, they should be encoded in a flags byte, and suitable getter/setter functions, taking TBools, should be coded to access that flags byte.