error: constructor is protected within this context
<pre><code>#include&lt;iostream&gt;
using namespace std;
class Base{
    private:
        int a;
    protected:
        Base(){};
        virtual ~Base(){};
};
class Derived:private Base{
    private:
        int b;
    public:
        Derived(){};
        ~Derived(){};
        void test(){
            Base world;
        };

};

int main(){
}
</code></pre>

<p>inherit.cc|7 col 3| error: ‘Base::Base()’ is protected<br>
inherit.cc|17 col 9| error: within this context<br>
inherit.cc|8 col 11| error: ‘virtual Base::~Base()’ is protected<br>
inherit.cc|17 col 9| error: within this context<br></p>

<p>But why?</p>

<p>And why this is correct?</p>

<pre><code>#include&lt;iostream&gt;
using namespace std;
class Base{
    private:
        int a;
    protected:
        Base(){};
        virtual ~Base(){};
        void test2(){};
};
class Derived:private Base{
    private:
        int b;
    public:
        Derived(){};
        ~Derived(){};
        void test(){
            test2();
        };

};

int main(){
}
</code></pre>
