C++11 supports constructor delegation

Oh yeah… oooh yeah.

C++11 supports constructor delegation.

class Foo
{
public: 
  Foo(char x, int y) : _x(x), _y(y) {}
  Foo(int y) : Foo('a', y) {} // This was forbidden in C++03

private:
  char _x;
  int _y;
};

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.