LyargoOS
User Center
 

Date
Sep. 27th, 2026
 
2026年九月廿七

Post: C++ Primer 004 : bool 类型

C++ Primer 004 : bool 类型

Table of Content

本篇主要介绍C++ 中的 bool 类型。

bool类型

bool 类型用来表示逻辑值,它只有两个值: true1 与 false,我们可以通过函数 boolalpha 来将 bool 值显示为 true 或 false 字面值。

bool 类型可以定义变量,也可以定义指针,可以作为函数的参数,也可以作为函数的返回值。

回顾 C 语言中的知识,取值为 0、0.0、NULL 或 \0 均可以表示为假。

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询。