Skip to content

Commit 0dd85de

Browse files
authored
Merge pull request #49 from YangZ2020/main
Update undef.md 中解引用笔误
2 parents 1496935 + b42f211 commit 0dd85de

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/undef.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,17 @@ bool 虽然占据 1 字节(8 位)内存空间,但其中只有一个有效
255255

256256
```cpp
257257
char c = 0;
258-
bool b = *(bool *)c; // 可以,b = false
258+
bool b = *(bool *)&c; // 可以,b = false
259259
```
260260

261261
```cpp
262262
char c = 1;
263-
bool b = *(bool *)c; // 可以,b = true
263+
bool b = *(bool *)&c; // 可以,b = true
264264
```
265265

266266
```cpp
267267
char c = 2;
268-
bool b = *(bool *)c; // 未定义行为
268+
bool b = *(bool *)&c; // 未定义行为
269269
```
270270

271271
## 算数类

0 commit comments

Comments
 (0)