面向对象之多态(抽象类)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 抽象类
{
    class Program
    {
        static void Main(string[] args)
        {
            animal a = new Dogs();
            animal b = new Cats();
            a.Bark();
            b.Bark();
            Console.ReadKey();


        }
        public abstract class animal
        { 
         public abstract void Bark();    
        }
        public class Dogs : animal
        {
            public override void Bark()
            {
                Console.WriteLine("小狗汪汪叫");
            }
        }
        public class Cats : animal
        {
            public    override void Bark()
            {
                Console.WriteLine("小猫喵喵叫");
            }
        }
    }
}

 

posted @ 2015-08-05 15:30  骏码信息  阅读(137)  评论(0)    收藏  举报