Content deleted Content added
No edit summary |
m →Initializer list: example was not well formatted |
||
Line 31:
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:
:struct int_complex {int re, im; complex() : re(0), im(0) { }};▼
struct int_complex {
int re, im;
};
Here, the construct " : re(0), im(0)" is the initializer list.
|