Initializer list
An initializer list is a brace-enclosed sequence of initial values used to initialize an object or supply initialization values to a construct.
Learn C++ by Example
An initializer list is a brace-enclosed sequence of initial values used to initialize an object or pass initialization values to a construct.
- How it is used
- Constructs vectors, objects, and temporary value sequences directly from known values.
- How deep it goes
- Explains brace syntax, constructor ambiguity, narrowing prevention, and practical container use without exploring initialization's full complexity.
- Examples
- Uses vector initialization, an integer declaration, and a card-deck suit list as concrete examples.
- What you can do after
- Apply it via std::vector, std::array, and object construction while avoiding unintended counts and narrowing conversions.
100 C++ Mistakes and How to Avoid Them
An initializer list is a sequence of initialization elements supplied using brace syntax to initialize objects, constructors, or containers.
- How it is used
- Initializes instance variables efficiently and establishes valid object state during construction.
- How deep it goes
- Explains declaration-order semantics, constructor-body drawbacks, uninitialized built-ins, and validation, but does not cover broader syntax.
- Examples
- Uses Person examples to contrast incorrect member order, constructor-body assignment, disciplined ordering, and validated age initialization.
- What you can do after
- Apply it via C++ constructor initializer lists to initialize every member, preserve dependencies, and validate parameters before use.
Read how 100 C++ Mistakes and How to Avoid Them explains initializer list →
Related concepts
- vectorproduces · A vector is an ordered, indexed sequence of elements, often numerical, represented as a mathematical quantity or a computational collection.
- instance variableuses · An instance variable is data associated with a particular object, rather than shared across all instances of its class or type.
- Mapconfigures · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
- default constructoraddresses · A default constructor is a constructor that can be invoked without caller-supplied arguments, whether explicitly declared or implicitly provided by a language or compiler.
- uniform initializationused by · Uniform initialization is C++ syntax that uses braces to initialize objects and values.
- copy assignment operatorcontrasts with · A copy assignment operator is a C++ special member function that copies state from one object into an already existing object of a compatible type.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

