C++11: Uniform Initialization explained with Simple example

In C++11 (Introduction to C++11), “Uniform initialization” syntax is introduced to initialize variables which provides a consistent syntax for all types of data variables initialization. This syntax is defined for all types of objects, arrays etc. In this post we are focusing on Uniform initialization syntax with some coding examples.

Earlier there were multiple ways to initialize variables. For example: basic data type variables could be initialized using assignment operator whereas class objects could be initialized using a constructor.

In C++11, a uniform way of initializing variables is introduced which is called “Uniform Initialization” syntax.

Let’s have a look at the sample code example to understand the usage of uniform initialization.

(more…)
C++11: Uniform Initialization explained with Simple example Read More