public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Defaulted initializer constructor
@ 2012-11-26  9:49 Henrik Mannerström
  2012-11-26 10:31 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Henrik Mannerström @ 2012-11-26  9:49 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-26 10:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-26  9:49 Defaulted initializer constructor Henrik Mannerström
2012-11-26 10:31 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).