Defaulted initializer constructor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux