Initialization (programming): Difference between revisions

Content deleted Content added
Line 33:
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">
 
struct int_complex {
int re, im;
complex() : re(0), im(0) { }
};
</source>
 
Here, the construct " : re(0), im(0)" is the initializer list.