I am trying to use the constructor inheritance feature of C++11. The following snippet (copied from somewhere, I don\'t remember whence) works completely fine:
#
The problem is that marking a copy constructor with delete
makes it user-declared, which in effect deletes the default constructor of that class (in your case Derived
). The behaviour can be seen in this simple code:
struct X
{
X(const X&) = delete; // now the default constructor is not defined anymore
};
int main()
{
X x; // cannot construct X, default constructor is inaccessible
}
As a side remark: even if Base::Base()
would be inherited, the compiler would see it like
Derived(): Base(){}
. But Derived
is deleted, so it cannot really call Base::Base()
. In general, a using Base::Base
statement is just syntactic sugar for the corresponding compiler-generated Derived(params): Base(params){}
.