例如
class A
{
int *p{}; // is this fine without giving the null pointer value 0?
int p[3]{}; // is this fine without double braces {{ }}? std::array need.
};
我的测试显示它们通过了Intel C ++编译器。但是不确定它们在标准上是否正确?
是的,是的。
最好使用nullptr进行显式初始化,例如int *p = nullptr;
。
int p[3]{}
将使用int {}初始化每个p。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句