本帖最后由 黄基焜 于 2012-9-8 00:24 编辑
今天看到老毕的一段代码如下:
class Employee
{
private String name;
private String id;
private double pay;
Employee(String name,String id,double pay)
{
this.name = name;
this.id = id;
this.pay = pay;
}
public void work(){};
}
class Manager extends Employee
{
private int bonus;
Manager(String name,String id,double pay,int bonus)
{
super(name,id,pay);
this.bonus = bonus;
}
public void work()
{
System.out.println("manager work");
}
}
class Pro extends Employee
{
Pro(String name,String id,double pay)
{
super(name,id,pay);
}
public void work()
{
System.out.println("pro work");
}
}
父类Employee中的私有成员name、id、poy可以给子类Manager继承到吗?
之前看老毕的视频听到父类成员private后,子类也不能引用。 |