本文介绍了C ++ 11从同一类类型的构造函数调用构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我被告知可能是由于C ++ 11的变化:
I was told the following was possible due to changes in C++11:
class SomeType {
int number;
public:
SomeType(int new_number) : number(new_number) {}
SomeType() : SomeType(42) {}
};
但是当我尝试构建时,我得到一个错误:
But when I try to build I get an error:
"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中还不支持此功能吗?我需要配置一些东西来让这个构建吗?错误是什么?
Is this feature not yet supported in Visual Studio 2010? Do I need to configure something to get this to build? What is wrong?
推荐答案
VS2010不支持。 VS2010(或VS11)中不支持大多数C ++ 11功能
It's not supported in VS2010. Most C++11 features are not supported in VS2010 (or VS11 for that matter)
是VC10和VC11中支持的功能的图表。
Here is a chart of supported features in VC10 and VC11.
这篇关于C ++ 11从同一类类型的构造函数调用构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!