3

I was just wondering if g++ actually complies with the C++11 standard of chained constructors (or whatever it's called).

example:

class MyClass
{
  MyClass(int x, int y = 0);
  MyClass(int y = 0) : MyClass(8, y) {}
};

I keep getting this error even though I've included the -std=c++0x (or -std=gnu++0x) parameter (there is no -std=c++11)

error: type ‘MyClass’ is not a direct base of ‘MyClass’

I don't want to jump to conclusions and I've looked around the net but can't seem to find any information about it.

By the way, I'm using g++ (Debian 4.6.2-4) 4.6.2

11

It's not yet supported (look for delegating constructors).

Other than that, don't you think your design is highly ambiguous? What should MyClass(1) call?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.