相关疑难解决方法(0)

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

有人告诉我,由于C++ 11的变化,以下内容是可能的:

class SomeType  {
int number;

public:
SomeType(int new_number) : number(new_number) {}
SomeType() : SomeType(42) {}
};
Run Code Online (Sandbox Code Playgroud)

但是当我尝试构建时,我收到一个错误:

"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
Run Code Online (Sandbox Code Playgroud)

Visual Studio 2010中是否还不支持此功能?我是否需要配置一些东西来构建它?怎么了?

c++ constructor visual-studio-2010 visual-c++ c++11

6
推荐指数
1
解决办法
1486
查看次数

标签 统计

c++ ×1

c++11 ×1

constructor ×1

visual-c++ ×1

visual-studio-2010 ×1