ILE C/C++ Language Reference

Boolean Conversions

C++You can convert integral, floating-point, arithmetic, enumeration, pointer, and pointer to member rvalue types to an rvalue of type bool. A zero, null pointer, or null member pointer value is converted to false. All other values are converted to true.

The following is an example of boolean conversions:

void f(int* a, int b)
{
  bool d = a;  // false if a == NULL
  bool e = b;  // false if b == 0
}

The variable d will be false if a is equal to a null pointer. Otherwise, d will be true. The variable e will be false if b is equal to zero. Otherwise, e will be true.

Related References


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]