If we have
// Uninitialized
MyStruct s;
// Direct list initialization
MyStruct s2{};
What are the differences?
My only guess here is that s
would have all of its members in an undefined state, where s2
has everything zeroed out based on what I've read online. I have no idea if this is true, and I'm not finding the answer by looking through the cppreference (most likely I missed it).
However I am unsure whether or not MyStruct s2{}
actually "zeros everything out" or whether it is identical to MyStruct s
and what I am saying above is wrong. Not sure what the difference is and what exactly is going on under the hood with these two statements. Further, if they do the exact same thing, then is one preferred over the other?