1、
abstract class Animal
{
public abstract void eat();
public abstract void bark();
}
class Dog : Animal
{
public override void eat()
{
Console.WriteLine("狗吃肉");
}
public override void bark()
{
Console.WriteLine("汪汪");
}
}
class Cat:Animal
{
public override void eat()
{
Console.WriteLine("猫吃鱼");
}
public override void bark()
{
Console.WriteLine("喵喵");
}
}
2、
abstract class Shape
{
public abstract double mianji();
public abstract double zhouchang();
}
class circle:Shape
{
public circle(double r)
{
this.r = r;
}
public double r
{
get;
set;
}
public override double mianji()
{
return Math.PI * this.r * this.r;
}
public override double zhouchang()
{
return 2 * Math.PI * this.r;
}
}