I don’t understand why is it possible to do this:
int numbers[] = {-4,3,0,100,2000};
Set d(5,numbers);
but I get the following error when trying to do this:
Set d(5,{-4,3,0,100,2000});
Error:
warning: extended initializer lists only available with -std=c++0x
or -std=gnu++0x|
error: no matching function for call to
'Set::Set(int, <brace-enclosed initializer list>)'
Constructor:
Set::Set(int size, const int constSet[])
Thanks for your help
This is not allowed in C++03, but the newest standard C++11 allows it.
See this: https://en.wikipedia.org/wiki/C%2B%2B11#Initializer_lists or this: https://www2.research.att.com/~bs/C++0xFAQ.html#init-list
By the way, your constructor is actually taking a pointer, not an array.