X
Xg__yeqingshan
Unregistered / Unconfirmed
GUEST, unregistred user!
using System;
public abstract class Employee
{
private string name;
private long idcard;
privatedo
uble salary;
privatedo
uble increase;
public Employee(string n,long i,do
uble m)
{
name=n;
idcard=i;
salary=m;
}
public abstract string Name{get;set;}
public abstractdo
uble Salary{get;set;}
public abstract long ID{get;set;}
public abstractdo
uble Increase{get;set;}
public abstract void Raise(double percent);
public abstract void Print();
}
public class WorkeEmp:Employee
{
public WorkeEmp(string n,long i,double m):base(n,i,m)
{}
public override String Name
{
get
{return name;}//提示不能访问此成员
set
{name=value;}
}
public overridedo
uble Salary
{
get
{return salary;}//同上
set
{salary=value;}
}
public override long ID
{
get
{return idcard;}
set
{idcard=value;}
}
public overridedo
uble Increase
{
get
{return increase;}
set
{increase=value;}
}
public override void Print()
{
Console.WriteLine("姓名:{0}",name);
Console.WriteLine("身份证号:{0}",idcard);
Console.WriteLine("基本工资:{0}",salary);
Console.WriteLine("增加工资额:{0}",increase);
}
public override void Raise(double percent)
{
Increase=percent*Salary;
}
}
public class BachelorEmp:Employee
{
public BachelorEmp(string n,long i,double m):base(n,i,m)
{}
public override String Name
{
get
{return name;}
set
{name=value;}
}
public overridedo
uble Salary
{
get
{return salary; }
set
{salary=value;}
}
public override long ID
{
get
{return idcard;}
set
{idcard=value;}
}
public overridedo
uble Increase
{
get
{return increase;}
set
{increase=value;}
}
public override void Print()
{
Console.WriteLine("姓名:{0}",name);
Console.WriteLine("身份证号:{0}",idcard);
Console.WriteLine("基本工资:{0}",salary);
Console.WriteLine("增加工资额:{0}",increase);
}
public override void Raise(double percent)
{
Increase=percent*Salary*2;
}
}
public class MasterEmp:Employee
{
public MasterEmp(string n,long i,double m):base(n,i,m)
{}
public override String Name
{
get
{return name;}
set
{name=value;}
}
public overridedo
uble Salary
{
get
{return salary; }
set
{salary=value;}
}
public override long ID
{
get
{return idcard;}
set
{idcard=value;}
}
public overridedo
uble Increase
{
get
{return increase;}
set
{increase=value;}
}
public override void Print()
{
Console.WriteLine("姓名:{0}",name);
Console.WriteLine("身份证号:{0}",idcard);
Console.WriteLine("基本工资:{0}",salary);
Console.WriteLine("增加工资额:{0}",increase);
}
public override void Raise(double percent)
{
Increase=percent*Salary*3;
}
}
public class EmpSalaryApp
{
public static void Main()
{
WorkeEmp w=new WorkeEmp("fsk",12365,155.0);
w.Raise(0.2);
w.Print();}
}
为什么抽象类中的私有成员不能被派生类访问?
多谢
public abstract class Employee
{
private string name;
private long idcard;
privatedo
uble salary;
privatedo
uble increase;
public Employee(string n,long i,do
uble m)
{
name=n;
idcard=i;
salary=m;
}
public abstract string Name{get;set;}
public abstractdo
uble Salary{get;set;}
public abstract long ID{get;set;}
public abstractdo
uble Increase{get;set;}
public abstract void Raise(double percent);
public abstract void Print();
}
public class WorkeEmp:Employee
{
public WorkeEmp(string n,long i,double m):base(n,i,m)
{}
public override String Name
{
get
{return name;}//提示不能访问此成员
set
{name=value;}
}
public overridedo
uble Salary
{
get
{return salary;}//同上
set
{salary=value;}
}
public override long ID
{
get
{return idcard;}
set
{idcard=value;}
}
public overridedo
uble Increase
{
get
{return increase;}
set
{increase=value;}
}
public override void Print()
{
Console.WriteLine("姓名:{0}",name);
Console.WriteLine("身份证号:{0}",idcard);
Console.WriteLine("基本工资:{0}",salary);
Console.WriteLine("增加工资额:{0}",increase);
}
public override void Raise(double percent)
{
Increase=percent*Salary;
}
}
public class BachelorEmp:Employee
{
public BachelorEmp(string n,long i,double m):base(n,i,m)
{}
public override String Name
{
get
{return name;}
set
{name=value;}
}
public overridedo
uble Salary
{
get
{return salary; }
set
{salary=value;}
}
public override long ID
{
get
{return idcard;}
set
{idcard=value;}
}
public overridedo
uble Increase
{
get
{return increase;}
set
{increase=value;}
}
public override void Print()
{
Console.WriteLine("姓名:{0}",name);
Console.WriteLine("身份证号:{0}",idcard);
Console.WriteLine("基本工资:{0}",salary);
Console.WriteLine("增加工资额:{0}",increase);
}
public override void Raise(double percent)
{
Increase=percent*Salary*2;
}
}
public class MasterEmp:Employee
{
public MasterEmp(string n,long i,double m):base(n,i,m)
{}
public override String Name
{
get
{return name;}
set
{name=value;}
}
public overridedo
uble Salary
{
get
{return salary; }
set
{salary=value;}
}
public override long ID
{
get
{return idcard;}
set
{idcard=value;}
}
public overridedo
uble Increase
{
get
{return increase;}
set
{increase=value;}
}
public override void Print()
{
Console.WriteLine("姓名:{0}",name);
Console.WriteLine("身份证号:{0}",idcard);
Console.WriteLine("基本工资:{0}",salary);
Console.WriteLine("增加工资额:{0}",increase);
}
public override void Raise(double percent)
{
Increase=percent*Salary*3;
}
}
public class EmpSalaryApp
{
public static void Main()
{
WorkeEmp w=new WorkeEmp("fsk",12365,155.0);
w.Raise(0.2);
w.Print();}
}
为什么抽象类中的私有成员不能被派生类访问?
多谢