public static class Employee{
private String Empname;
private String EmpNo;
private double salary;
public Employee() {
}
public Employee(String empname, String empNo, double salary) {
super();
Empname = empname;
EmpNo = empNo;
this.salary = salary;
}
public String getEmpname() {
return Empname;
}
public void setEmpname(String empname) {
Empname = empname;
}
public String getEmpNo() {
return EmpNo;
}
public void setEmpNo(String empNo) {
EmpNo = empNo;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}
public class Manager extends Employee{
//奖金属性
private double bonus;
public Manager(String empname, String empNo, double salary, double bonus) {
super(empname, empNo, salary);
this.bonus = bonus;
}
public double getBonus() {
return bonus;
}
public void setBonus(double bonus) {
this.bonus = bonus;
}
}
public static void main(String[] args) {
Employee em = new Employee("张三","yuangong001",3000);
System.out.println(em.getEmpname() +" "+ em.getEmpNo() +" "+ em.getSalary());
Manager ma = new Manager("李四","jingli001",5000,10000);
System.out.println(ma.getEmpname() +" "+ ma.getEmpNo() + " " + ma.getSalary() + " " + ma.getBonus());
}
红字部分提示No enclosing instance of type Test2b is accessible. Must qualify the allocation with an enclosing instance of type Test2b (e.g. x.new A() where x is an instance of Test2b).
请问原因和解决办法
|
|