I run across a weird concept named "member initializer".
Here says:
C++11 added member initializers, expressions to be applied to members at class scope if a constructor did not initialize the member itself.
What is its definition?
Are there some examples to illustrate its usage?
It probably refers to in-class member initializers. This allows you to initialize non-static data members at the point of declaration:
struct Foo
{
explicit Foo(int i) : i(i) {} // x is initialized to 3.1416
int i = 42;
double x = 3.1416;
};
More on that in Bjarne Stroustrup's C++11 FAQ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With