:base()

namespace Ch13CardLib
{
   public class CardOutOfRangeException : Exception
   {
      private Cards deckContents;

      public Cards DeckContents
      {
         get
         {
            return deckContents;
         }
      }

      public CardOutOfRangeException(Cards sourceDeckContents) : base("There are only 52 cards in the deck.")
      {
         deckContents = sourceDeckContents;
      }
   }
}

 

:base()是先执行父类的构造函数,然后在执行自己的。

 

子类的构造函数执行的时候,会先调用父类中的构造函数。

posted @ 2009-07-14 14:28  适渊  阅读(237)  评论(0编辑  收藏  举报