日期:2014-05-20  浏览次数:20628 次

接口无法实现的小问题。。。。分数不多,请大侠帮忙!!
这是《C#高级编程》里的一个例子,官方网站太慢上不去,只能在这里提问了。。。

Bank.cs:

        public   interface   IBankAccount
        {
                void   PayIn(decimal   amount);
        }

        public   class   GoldAccount   :   IBankAccount
        {
                private   decimal   balance;
                public   void   PayIn(decimal   amount)
                {
                    //........
                }
        }

        public   class   SaverAccount   :   IBankAccount
        {
                private   decimal   balance;
                public   void   PayIn(decimal   amount)
                {
                        //......
                }
        }

        //派生的接口

        public   interface   ITransferBankAccount   :   IBankAccount
        {
                bool   TransferTo(IBankAccount   destination,   decimal   amount);
        }
        public   class   CurrentAccount:ITransferBankAccount
        {
                private   decimal   balance;
                public   void   PayIn(decimal   amount)
                {
                        //.....
                }
                public   bool   TranferTo(IBankAccount   destination,   decimal   amount)
                {
      //代码略~
                }//问题就在这里了。。
        }

Program.cs:
                static   void   Main(string[]   args)
                {
                        IBankAccount   venusAccount   =   new   SaverAccount();
                        CurrentAccount   jupiterAccount   =   new   CurrentAccount();
                        venusAccount.PayIn(200);
                        jupiterAccount.PayIn(500);
                        jupiterAccount.TransferTo(venusAccount,   100);//这里...