To see that the member-variable protection imposed by a protected
derivation persists in classes derived from the subclass, suppose
that you define a refrigerator_car
class to be a class derived from
the box_car
class. Further suppose that the derivation is public or
protected. Then, if you define a display_height
function in the
refrigerator_car
class definition, that display_height
function can get at the height
member variable declared in the
box
class definition:
box <-- Height declared to be a public member variable ^ | <-- Protected derivation | box_car <-- Height member variable acts as though protected ^ | <-- Public derivation | refrigerator_car <-- Height member variable is accessible to member functions