It is called Initialization list in C++.
In initializes your variables x
, y
and z
.
In this case(assuming x
, y
& z
are int
) it is same as:
x = 0
y = 0
z = 0
As @Charles Bailey, appropriately points out, In case the types are not int
but some custom user defined class then assignment & construction maynot be the exact equivalents.
Explanation:
In an Initializer list, the types are Initialized by calling appropriate default constructors on each of the variable, for an inbuilt data type like int
this is same as assignment but for custom classes an constructor operation might be different from assignment operation.