< Previous | Contents | Next >

Controlling Access under Inheritance

When you derive one class from another, you can control how much access the derived class has to the base classmembers. For the same reasons that you want to provide only as much access as is necessary to a classmembers to the rest of your program, you want to provide only as much access as is necessary to a classmembers to a derived class. Not coincidentally, you use the same access modifiers that youve seen beforepublic, protected, and private. (Okay, you havent seen protected before, but Ill explain that modifier in the Using Access Modifiers with Class Memberssection.)

338 Chapter 10 n Inheritance and Polymorphism: Blackjack


 

Introducing the Simple Boss 2.0 ProgramUsing Access Modifiers with Class MembersUsing Access Modifiers When Deriving Classes