Suppose I have a struct called foo_boolean that contains some boolean values:
struct foo_boolean {
bool b1;
bool b2;
};
If I define a variable of type foo_boolean without initializing it, what will the default value of the member variables be? (i.e., true, false, or a random value of the two.)
It depends on how you create it. If the struct is constructed by default-initialization e.g.
then the values will be undefined (bad things will happen if you read it before setting a value).
On the other hand, if the struct is constructed by value-initialization or zero-initialization e.g.
then the values will be zero, i.e. false.