Is there any difference regarding the initialization of the x member variable in these cases:
struct A {
int x;
A() {}
};
struct B {
int x;
B() : x(0) {}
};
struct C {
int x;
C() : x() {}
};
For all these cases, in the tests I did, x is always set to the initial value of 0. Is this a guaranteed behavior? Is there any difference in these approaches?
A::xis uninitialized. Demo.0is just as uninitialized as any other value. You know a value is initialized by following the rules of initialization, whichBandCdo successfully.struct A { int x = 0; /*...*/ }might be interesting to compare...