Initialization (programming): Difference between revisions

Content deleted Content added
Initializer list: formatting, concision
Line 33:
 
===Initializer list===
In C++, a [[constructor]] of a class/struct can have an '''initializer list''' within the definition but prior to the constructor body. It assigns initial values to the members of the class/struct object.
Example:
<source lang="c">
Line 41:
};
</source>
Here, the construct "<code> : re(0), im(0)"</code> is the initializer list.
 
Sometimes the term "initializer list" is also used to refer to the list of expressions in the array or struct initializer.
 
The new C++ standard, [[C++11]], provides for a [[C++11#Initializer_lists|more powerful concept of initializer lists]], by means of a template, called <tt>std::initializer_list</tt>.
 
===Default initialization===