C ++ 11从相同类类型的构造函数中调用构造函数

时间:2012-05-03 00:05:00

标签: c++ visual-studio-2010 visual-c++ constructor c++11

有人告诉我,由于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中是否尚不支持此功能?我是否需要配置一些东西来构建它?有什么问题?

1 个答案:

答案 0 :(得分:10)

VS2010不支持。 VS2010(或VS11)不支持大多数C ++ 11功能

Here是VC10和VC11支持功能的图表。

相关问题