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

标签 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 尚不支持此功能吗?我需要配置一些东西来构建它吗?怎么了?

最佳答案

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

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

关于C++11 从相同类类型的构造函数调用构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10423401/

相关文章:

c++ - 为什么通过指针调用 std::stringstream good() 会导致崩溃?

c++ - 在 Windows 上使用 clang 链接 msvc 内在函数的问题

c++ - 调用 std::condition_variable 后因无效参数导致应用程序崩溃

c++ - 循环中的 Poco ScopedLock

c++ - 实现C++ 20 bidirectional_iterator概念

visual-studio-2010 - NuGet软件包还原退出,代码为-1

asp.net-mvc - 找不到类型或命名空间名称 'DbContext'

C++:使用指向 unordered_map 的指针或只是将其定义为类中此类型的成员变量?

c++ - 为什么将值初始化指定为不调用平凡的默认构造函数?

html - Visual Studio 2010 是否支持 HTML 5?