Have a look at this code snippet
struct S{ int i; int j;};
int main()
{
assert(S().i == S().j) // is it guaranteed ?
}
Why?
is it guaranteed ?
Yes it is guaranteed. The values of S().i
and S().j
would be 0
. ()
implies value initialization. (that means i
and j
would be zero-initialized because S
is a class without a user defined default constructor)