c++ - How private inheritance allowed me to create object? -



c++ - How private inheritance allowed me to create object? -

i have simple code, assume failed.

i have privately inherit shield sealer, , shield not it's friend, still able create object of shield.

class sealer { public: sealer() { cout<<"base constructor;"<<endl; } }; class shield : private sealer { public: void p() { cout<<"p gets called;"<<endl; } }; int main() { shield d; //success here d.p(); // here homecoming 0; }

how possible? base of operations class constructor should not accessible. isn't it?

i using visual studio 2012.

class shield : private sealer means in sealer kept private within shield; cannot seen outside shield or in classes derived it.

it not magically go , create sealer's constructor private shield cannot access it. point of private inheritance if kid class not access base of operations class? nothing.

c++ visual-studio visual-c++ inheritance private

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -