I was asking myself something this morning, and I can't find the words to properly "google" for it:
Lets say I have:
struct Foo
{
int bar;
};
struct Foo2
{
int bar;
Foo2() {}
};
struct Foo3
{
int bar;
Foo3() : bar(0) {}
};
Now, if I default-initialize Foo
, Foo2
and Foo3
:
Foo foo;
Foo2 foo2;
Foo3 foo3;
In which case(s) is the bar
member properly initialized, meaning that its value isn't indeterminate?
Note: Foo3
obviously initialized. It is only shown here to display the difference to Foo2
, so the question is mainly about the first two.
foo
,foo2
andfoo3
in the global namespace scope or in a function? – Aboral