构造函数 面试

 

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    //输出的结果是ABAB
    class Program
    {
        static void Main(string[] args)
        {
            a a = new b();
            b b = new b();
           // c c = new a();//这样调是错的

        }
    } 
    public  class a
    {
         public  a()
      {
          Console.WriteLine("a");
          Console.Read();
         }
    }
   public  class b:a
   {

       public b()
       {
           Console.WriteLine("b");
           Console.Read();

       }
    }
    public class c : a
    {
        c()
        {
            Console.WriteLine("c");
        }
    }
}

 

posted @ 2010-04-15 14:32  红萝卜  阅读(165)  评论(0编辑  收藏  举报