我遇到一个名为“成员初始化器”的怪异概念.
Here说:
C++11 added member initializers,expressions to be applied to members
at class scope if a constructor did not initialize the member itself.
它的定义是什么?
有没有一些例子说明其用法?
解决方法
它可能是指类成员初始化器.这允许您在声明点初始化非静态数据成员:
struct Foo { explicit Foo(int i) : i(i) {} // x is initialized to 3.1416 int i = 42; double x = 3.1416; };