CHAPTER 6 UNDERSTANDING INHERITANCE AND POLYMORPHISM
As you would guess, there are many more details to inheritance that you will come to know during
the remainder of this chapter. For now, simply keep in mind that the colon operator allows you to
establish base/derived class relationships, while the sealed keyword prevents subsequent inheritance
from occurring.
Revising Visual Studio Class Diagrams
In Chapter 2, I briefly mentioned that Visual Studio allows you to establish base/derived class
relationships visually at design time. To leverage this aspect of the IDE, your first step is to include a new
class diagram file into your current project. To do so, access the Project Add New Item menu option
and select the Class Diagram icon (in Figure 6-2, I renamed the file from ClassDiagram1.cd to Cars.cd).
Figure 6-2. Inserting a new class diagram
After you click the Add button, you will be presented with a blank designer surface. To add types to a
class designer, simply drag each file from the Solution Explorer window onto the surface. Also recall that
if you delete an item from the visual designer (simply by selecting it and pressing the Delete key), this
will not destroy the associated source code, but simply removes the item off the designer surface. The
current class hierarchy is shown in Figure 6-3.
218