cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

Initialization from {}

Open shaneasd opened this issue 3 years ago • 0 comments

Channel C++Weekly

Topics

value initialization aggregate initialization zero initialization

Length

Should this be bite-sized (5-10 minutes) or more long form (10-20 minutes)? Unsure.

I was 99% confident that if I have

struct X
{
   float a[2];
   float b;
};
X x[3]{};

that x will be zero initialized (i.e. all of those floats will be zero). I wanted to be 100% sure so I looked up the various relevant pages on cppreference and now I'm 95% sure.

shaneasd avatar Aug 03 '22 16:08 shaneasd