i wrote this program in VC++ 2010:
class class1
{
public:
class1 (initializer_list<int> a){};
int foo;
float Bar;
};
void main()
{
class1 c = {2,3};
getchar();
}
but i get this errors when i compile project:
Error 1 error C2552: ‘c’ :
non-aggregates cannot be initialized
with initializer
list c:\users\pswin\documents\visual
studio
2010\projects\test_c++0x\test_c++0x\main.cpp 27
and
2 IntelliSense: initialization with
‘{…}’ is not allowed for object of
type
“class1” c:\users\pswin\documents\visual
studio
2010\projects\test_c++0x\test_c++0x\main.cpp 27
what is the problem?
It shouldn’t be supported at all:
The error message refers to the pre-C++0x feature of aggregate initialization, which allows the initialization of certain user-defined types by using curly braces:
Aggregates are defined in §8.5.1: