Defaulted initializer constructor
Henrik Mannerström
henrik.mannerstrom@gmail.com
Mon Nov 26 09:49:00 GMT 2012
Hello!
If I write
class MT {
public:
int k[3];
};
then g++(4.6.3) accepts
MT a{{0,1,2}};
but if I add a constructor
MT() {
for (int i = 0;i!=3;i++)
k[i] = 0;
}
then MT a{{0,1,2}}; gives me
error: no matching function for call to ‘MT::MT(<brace-enclosed
initializer list>)Â’
Now, if I add
MT(std::initializer_list<int> list) = default;
I get
error: ‘MT::MT(std::initializer_list<int>)’ cannot be defaulted
What constructor was I (gcc) using earlier and how can I get i back?
BR,
Henrik Mannerstrom
More information about the Gcc-help
mailing list