Figure 6-9.
The shapes hierarchy
Much like the employee hierarchy, you should be able to tell that you don’t want to allow the
object user to create an instance of Shape directly, as it is too abstract of a concept. Again, to prevent
the direct creation of the Shape type, you could define it as an abstract class. As well, given that we
wish the derived types to respond uniquely to the Draw() method, let’s mark it as virtual and define
a default implementation:
Do'stlaringiz bilan baham: