作者: 万大述 时间: 2013-6-25 17:17
作为子类应该也差不多吧~作者: aa26963 时间: 2013-6-26 08:46
abstract class Person
{
public abstract void homework();
}
class Student:Person
{
public override void homework()
{
Console.WriteLine("我是学生,我会收作业");
}
}
class Teacher : Person
{
public override void homework()
{
Console.WriteLine("我是老师,我会收作业");
}
}
class Headmaster : Person
{
public override void homework()
{
Console.WriteLine("我是校长,我才不会收作业");
}
}
class Program
{
static void Main(string[] args)
{
Student stu = new Student();
stu.homework();
Teacher tea = new Teacher();
tea.homework();
Headmaster master = new Headmaster();
master.homework();