...

/

Unified Initialization with {}

Unified Initialization with {}

In this lesson, we will learn how to initialize variables using {}.

The initialization of variables became uniform in C++11. For unified initialization, we need the {} brackets.

{} initialization is always applicable.

Direct initialization #

Variables can be declared directly without the assignment operator:

std::string str{"my String"};
int i{2011};

Copy initialization

...