有人告诉我,由于 C++11 的变化,以下内容是可能的:
class SomeType {
int number;
public:
SomeType(int new_number) : number(new_number) {}
SomeType() : SomeType(42) {}
};
但是当我尝试构建时出现错误:
"SomeType" is not a nonstatic data member or base class of class "SomeType"
error C2614: 'SomeType' : illegal member initialization: 'SomeType' is not a base or member
Visual Studio 2010 尚不支持此功能吗?我需要配置一些东西来构建它吗?怎么了?
最佳答案
它在 VS2010 中不受支持。 VS2010(或 VS11)不支持大多数 C++11 功能
Here是 VC10 和 VC11 中支持的功能的图表。
关于C++11 从相同类类型的构造函数调用构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10423401/