Reputation: 1940
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)?
Upvotes: 3
Views: 50