Constructor with default arguments can not be called when inherited

61 Views Asked by At

Please take a look at the code:

struct X {};

struct Foo {
    Foo (int n = {}, int p = {}) {}
};

struct Boo : Foo {
    using Foo::Foo;

    Boo (X n) {}
};

And usage:

Boo boo1;

Error message (GCC 5.2.1):

error: no matching function for call to ‘Boo::Boo()’

I know that Boo has no default constructor, but constructor of Foo has been inherited and can not be called this way. Why? Does it mean that inherited constructor can only by called if derived class has no constructor (or default one)?

0

There are 0 best solutions below