知识基础 -> 抽象类
作者:互联网
void Main()
{
Dog dog = new Dog();
dog.Bark();
Cat cat = new Cat();
cat.Bark();
}
public abstract class Animal
{
public abstract void Bark();
}
public class Dog : Animal
{
public override void Bark()
{
Console.WriteLine("狗会汪汪叫");
}
}
public class Cat : Animal
{
public override void Bark()
{
Console.WriteLine("猫会喵喵叫");
}
}
抽象类特点 -> 1. abstract关键字,不能有实现
2. 不能被实例化
3. 访问修饰符不能为private
标签:void,知识,基础,abstract,public,class,Animal,Bark,抽象类 来源: https://www.cnblogs.com/chengxunyuanxiaolv/p/16398528.html