••• Unprocessable paragraph: \start
Home Segments Index Top Previous Next

526: Mainline

\slidefont

••• Unprocessable paragraph: To see that the member-variable privatization imposed by a private derivation blocks access in classes derived from the subclass, you can suppose that you define a \code{refrigerator_car} class to be a class derived from the \code{box_car} class. Once again, suppose that the derivation is public or protected. This time, however, if you define a \code{display_height} function in the \code{refrigerator_car} class definition, that \code{display_height} function \ital{cannot} get at the \code{height} member variable declared in the \code{box} class definition: \begincode \par C:\Phw\Onto\CPP\protectb.tex •••

box <– Height declared to be a public member variable ^ | <– Private derivation | box_car <– Height member variable acts as though private ^ | <– Public derivation | refrigerator_car <– Height member variable not accessible to member functions Evidently, access to the height member variable is blocked by the private nature of the way the box_car class is derived from the box class. C:\Phw\Onto\CPP\protectb.tex •••