Named Initialization of Class Members

Get the details of designated initialization in C++20.

Designated initialization enables the direct initialization of members of a class type using their names. For a union, only one initializer can be provided. As for aggregate initialization, the sequence of initializers in the curly braces has to match the declaration order of the members.

Designated initialization

Get hands-on with 1200+ tech skills courses.