What does inheritance model in C++, and what is and is not inherited by a derived class?
Show answer and explanation
A derived object contains its base-class subobject, and public inheritance should model substitutability: code expecting the base contract can use the derived object correctly. Base members participate in lookup, and access checking then determines whether derived code may name them; private base state still exists but cannot be accessed directly by the derived class. Constructors and destructors are not inherited as ordinary members, a using-declaration only makes selected base constructors available, and friendship is not inherited; access mode also changes how base public and protected members are exposed.
A derived object contains its base-class subobject, and public inheritance should model substitutability: code expecting the base contract can use the derived object correctly. Base members participate in lookup, and access checking then determines whether derived code may name them; private base state still exists but cannot be accessed directly by the derived class. Constructors and destructors are not inherited as ordinary members, a using-declaration only makes selected base constructors available, and friendship is not inherited; access mode also changes how base public and protected members are exposed.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.