cpp_weekly
cpp_weekly copied to clipboard
Initialization from {}
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.