Skip to content

Initialization from {} #101

@shaneasd

Description

@shaneasd

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions