Newbie question on the 2nd ed: Class inheritance
The example on page 1162 (Appendix A, Adding Inheritance section), shows that the field "private decimal balance" from the base class "Customer" is changed to "protected decimal balance". On page 1163 it is stated that the reason is that so the derived class "Nevermore60Customer" can access "balance" field. My question is, why the "name" field on the base class is not changed to protected also? Because the derived class needs to access it to, right?
Is "protected" only used in inheritance? Because in instantiating, the instance class also needs to access the fields from the base class. Should the fields in the base class need to be changed to protected also?
Thanks
|