Question: Chapter 11 Some programmers prefer not to use protected access because they believe it breaks the encapsulation of the base class. Discuss the relative merits
Some programmers prefer not to use protected access because they believe it breaks the encapsulation of the base class. Discuss the relative merits of using protected access vs. using private access in base classes. Draw an inheritance hierarchy for students at a university similar to the hierarchy shown in Fig. 11.2. Use Student as the base class of the hierarchy, then include classes UndergraduateStudent and GraduateStudent that derive from Student. Continue to extend the hierarchy as deep (i.e., as many levels) as possible. For example. Freshman, Sophomore, Junior and Senior might derive from UndergraduateStudent. and DoctoralStudent and Masters-Student might derive from GraduateStudent. After drawing the hierarchy, discuss the relationships that exist between the classes. The world of shapes is much richer than the shapes included in the inheritance hierarchy of Fig. 11.3. Write down all the shapes you can think of-both two-dimensional and three-dimensional- and form them into a more complete Shape hierarchy with as many levels as possible. Your hierarchy should have the base-class Shape from which class TwoDimensionalShape and class ThreeDimensionalShape are derived
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
