上次快写完了电脑给我蓝屏了,这次我直接贴代码吧
//父类 基类
public class person
{
public person()
{
}
public person(string name, string sex, int age)
{
this.name = name;
this.sex = sex;
this.age = age;
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string sex;
public string Sex
{
get { return sex; }
set { sex = value; }
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
}
public class Student : person
{
public Student(string name, string sex, int age)
: base(name, sex, age)
{
}
//这里子类可以定义自己的字段
public Student(string name, string sex, int age, string love)
: base(name, sex, age)
{
this.love = love;
}
private string love;
public string Love
{
get { return love; }
set { love = value; }
}
}
我理解的大致是这样,不知道我这么理解的对不对, |