You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp/bool-cpp.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,10 @@ manager: "ghogen"
18
18
ms.workload: ["cplusplus"]
19
19
---
20
20
# bool (C++)
21
+
21
22
This keyword is a built-in type. A variable of this type can have values [true](../cpp/true-cpp.md) and [false](../cpp/false-cpp.md). Conditional expressions have the type `bool` and so have values of type `bool`. For example, `i!=0` now has **true** or **false** depending on the value of `i`.
22
23
23
-
**Visual Studio 2017 version 15.3 and later** (available with [/std:c++17](../build/reference/std-specify-language-standard-version.md)): The operand of a postfix or prefix increment or decrement operator may not be of type `bool`. In other words, given a variable **b** of type **bool**, these expressions are no longer allowed:
24
+
**Visual Studio 2017 version 15.3 and later** (available with [/std:c++17](../build/reference/std-specify-language-standard-version.md)): The operand of a postfix or prefix increment or decrement operator may not be of type **bool**. In other words, given a variable **b** of type **bool**, these expressions are no longer allowed:
24
25
25
26
```cpp
26
27
b++;
@@ -29,28 +30,29 @@ This keyword is a built-in type. A variable of this type can have values [true](
29
30
--b;
30
31
```
31
32
32
-
The values **true** and **false** have the following relationship:
33
+
The values **true** and **false** have the following relationship:
33
34
34
-
```
35
+
```cpp
35
36
!false == true
36
37
!true == false
37
38
```
38
39
39
-
In the following statement:
40
+
In the following statement:
40
41
41
-
```
42
+
```cpp
42
43
if (condexpr1) statement1;
43
44
```
44
45
45
-
If `condexpr1` is **true**, `statement1` is always executed; if `condexpr1` is **false**, `statement1` is never executed.
46
+
If `condexpr1` is **true**, `statement1` is always executed; if `condexpr1` is **false**, `statement1` is never executed.
46
47
47
-
When a postfix or prefix `++` operator is applied to a variable of type `bool`, the variable is set to **true**.
48
-
**Visual Studio 2017 version 15.3 and later**: operator++ for bool was removed from the language and is no longer supported.
48
+
When a postfix or prefix **++** operator is applied to a variable of type **bool**, the variable is set to **true**.
49
+
**Visual Studio 2017 version 15.3 and later**: operator++ for **bool** was removed from the language and is no longer supported.
49
50
50
-
The postfix or prefix `--` operator cannot be applied to a variable of this type.
51
+
The postfix or prefix **--** operator cannot be applied to a variable of this type.
51
52
52
-
The `bool` type participates in integral promotions. An r-value of type `bool` can be converted to an r-value of type `int`, with **false** becoming zero and **true** becoming one. As a distinct type, `bool` participates in overload resolution.
53
+
The **bool** type participates in integral promotions. An r-value of type **bool** can be converted to an r-value of type **int**, with **false** becoming zero and **true** becoming one. As a distinct type, **bool** participates in overload resolution.
0 commit comments