布尔类型的默认构造函数值 [英] Default constructor value for bool type
本文介绍了布尔类型的默认构造函数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
布尔类型的默认构造函数在C ++中返回哪个值?
Which value does the default constructor of the bool type return in C++?
例如,写作
int i = int();
保证变量 i 始终以0开头.
guarantees that the variable i will be initiated always with 0.
我想这样的初始化例程也是可能的:
I guess such an initialization routine is possible as well:
bool b = bool();
但是不幸的是,我找不到任何地方定义了这样的值,例如默认的bool构造函数返回.变量 b 是否始终使用 false 或 true 初始化.
But unfortunately I could not find anywhere which value such a default bool constructor is defined to return. Is the variable b always initialized with false or true.
推荐答案
false
.
在C ++ 14草案N4296第8.5节(初始化程序)第6段中列出了项目1和其中的引用,在第8段中列出了项目4.
Seen in the C++14 draft N4296, section 8.5 (Initializers), paragraph 6, list item 1 and references therein, and paragraph 8, list item 4.
这篇关于布尔类型的默认构造函数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文