The fact that a private instance variable of a base class cannot be accessed in the definition of a method of a derived class often seems wrong to people. After all, if you are an hourly employee and you want to change your name, nobody says, “Sorry, name is a private instance variable of the class Employee.” After all, if you are an hourly employee, you are also an employee. In Java, this is also true; an object of the class HourlyEmployee is also an object of the class Employee. However, the laws on the use of private instance variables and methods must be as we described, or else they would be compromised. If private instance variables of a class were accessible in method definitions of a derived class, then anytime you wanted to access a private instance variable, you could simply create a derived class
http://www.tanhuanyao.com http:// tanhuanyao.com http://www.bianshayao.com/ http://bianshayao.com/