protected inherientence with virtual function
<p>I write a virtual function with protected inherientence</p>

<pre><code>#include&lt;iostream&gt;
using namespace std;
class D{
private:
    int a;
protected:
    int b;
public:
    D(){a=b=c=0;}
    virtual void f(){
    a=2;
    cout &lt;&lt;"D::f"&lt;&lt;a&lt;&lt;endl;
    }
    void g(){cout&lt;&lt;"D::g"&lt;&lt;a&lt;&lt;endl;}
    int c;
};
class E:protected D{
    private:
        int a,b,c;
    public:
        E(){a=b=c;}
        void f(){
            a=3;
            cout&lt;&lt;"E::f"&lt;&lt;a&lt;&lt;endl;
        }
        void g(){cout&lt;&lt;"E::g"&lt;&lt;a&lt;&lt;endl;}
};
int main(){
    D *d = new E;
    d-&gt;f();
    d-&gt;g();
    return 0;
}
</code></pre>

<p>but if I use it, it turn out inaccessible base.</p>

<p>If I change it to public inherience , it can run.</p>

<p>I wonder that why I cannot use  D *d = new E; with private and protected inherience?</p>

<p>Thx in advance.</p>
