Skip to content
jieqi's archive
Go back

C++: Initialisation Methods

Six ways to write “give this variable a value”, and they aren’t interchangeable. Two can leave you with garbage, one changes which constructors are allowed to run, and one quietly prefers a different constructor from the one you meant.

The matrix below is per type, because that’s what decides the answer. Then the initializer_list hijack, what braces buy you, aggregates, and member init order.

It’s also on its own page if you want it full width.

Previous Post
C++: ODR and Linkage
Next Post
C++: STL internals