Main Page
Using Protected Inheritance
When you declare a member of a base class protected, it's available throughout that class, and in any derived classes, but nowhere else. You can see an example of this in the Inheritance example on the CD-ROM, as discussed in the In Depth section of this chapter. In that example, I pass the main Windows form of the program to the Animal class's constructor (so that class can display text in the main window). That form is stored in the Animal class's MainForm variable. Because derived classes also will need to use MainForm, but no one else will, I made that variable protected (also discussed in the In Depth section of this chapter):