Given
class Foo {
public:
bool *b;
Foo();
};
Foo::Foo()
:b()
{
}
int main()
{
Foo foo;
}
What does the b() do in the class initializer list? It seems to maybe initialize the pointer's value to 0.
This is value initialization; as the effect, built-in types will be zero-initialized. That means b will be initialized to 0 (the null pointer).
4) otherwise, the object is zero-initialized.
and
If T is a scalar type, the object's initial value is the integral constant zero explicitly converted to T.
and also
Zero- and value-initialization also initialize pointers to their null values.
bbe a null pointer