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

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -