为什么一个包中的子类不能通过超类的引用访问它的超类(位于另一个包中)的protected成员?我正为这一点而苦苦挣扎。请帮助我。
package points;
public class Point {
protected int x, y;
}
package threePoint;
import points.Point;
public class Point3d extends Point {
protected int z;
public void delta(Point p) {
p.x += this.x; // compile-time error: cannot access p.x
p.y += this.y; // compile-time error: cannot access p.y
}