// Add back the default ctor
// in the Manager class as well.
public SalesPerson() {}
Keeping Family Secrets: The protected Keyword
As you already know, public items are directly accessible from anywhere, while private items cannot
be accessed from any object beyond the class that has defined it. Recall from Chapter 5 that C#
takes the lead of many other modern object languages and provides an additional keyword to
define member accessibility: protected.
When a base class defines protected data or protected members, it establishes a set of items
that can be accessed directly by any descendent. If you wish to allow the SalesPerson and Manager
child classes to directly access the data sector defined by Employee, you can update the original
Employee class definition as follows:
Do'stlaringiz bilan baham: |