Reply to thread

If the function is required by the base class then it needs to be defined in the base class. You could add an abstract function to the base class though and only implement it in the sub class.

[code=csharp]

using System;


namespace Reeks6

{

    abstract class BankAccount

    {

        //constructor

        public abstract bool CanDebit(double amount);


        public void Debit(double amount)

        {

            if (CanDebit(amount))

            {

                balance -= amount;

                Console.Write("Debit succeeded ");

            }

        }

    }

}

[/code]


edit : typo


Back
Top