Uniform Initialization with {}

In this lesson, we will learn about initialization with {} and how it prevents narrowing.

The initialization of variables was uniform in C++11.

Two Forms of Initialization

Rule: A {}-Initialization is always applicable.

Direct Initialization

string str{"my String"};

Copy Initialisation

string str = {"my String"};

Get hands-on with 1000+ tech skills courses.