const关键字了解一下, 被const常量修饰的变量,会默认成常量,要么默认构造函数自己初始化,要么你要做初始化。
擦擦,你声明类为const,类内一个成员变量又定义成mutable,这两个关键字反义啊。
你试着去掉 mutable,他会默认调用构造函数,是可以的
或者你就不要用const。。。
我的理解是const和mutable是反义的。
如果你定义const Person变量而不提供初始值,那么Person类必须有默认构造函数。
From the C++03 Standard
8.5 [dcl.init] paragraph 9
If no initializer is specified for an object, and the object is of (possibly cv-qualified) non-POD class type (or array thereof), the object shall be default-initialized; if the object is of const-qualified type, the underlying class type shall have a user-declared default constructor.
可能是提示你最好有一个构造函数来初始化m_A